我想进入R并在shell脚本中加载一个库来做一些分析,但是我遇到了这样的错误
syntax error near unexpected token `GenomicRanges'这是我的shell脚本(我已经在bash_profile中加载了R模块)
#$ -S /bin/bash
for sample in *.txt; do
R # Enter R
library(GenomicRanges) # Load library
##
do some analysis later
##
done有什么方法可以在shell脚本中加载R库并运行一些分析吗?
发布于 2014-01-09 23:27:08
使用本文档符号(<<):
for sample in *.txt; do
R --no-save<<EOF
library(GenomicRanges)
read.table(file = "$sample", ...)
# some R code ...
....
EOF
done注意,在脚本中,您可以引用其他shell变量,例如$sample。小心避免使用反斜杠:$在R代码中出现的所有$。
https://stackoverflow.com/questions/21033208
复制相似问题