我正在尝试使用 makefile 自动执行一些 R 分析。分析是每月的数据分析和报告。到目前为止它运行良好,但为了扩展它,我希望默认操作是创建当前报告,但如果需要能够指定一个月。
我在将默认报告周期(由 R 脚本计算)分配给 makefile 变量时遇到问题。
生成文件
# Assign a data identifier.
#IRL could use R to assign current if not specified as an arg to make
month := $(Rscript './R/reportperiod.R')
test:
echo $(month)
reportperiod.R脚本是
要求(润滑)
cat(format(floor_date(as.POSIXct(Sys.time())-10*24*60*60, unit="month"), format="%Y%b"))
但这只是显示
echo
暗示脚本值尚未分配给变量。
最佳答案
我想你应该使用 $(shell ...) 函数来初始化 month 变量:
month := $(shell $(R_HOME)/bin/Rscript ./R/reportperiod.R)
关于r - 将 RScript 的输出分配给 makefile 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14945855/