3

我正在尝试使用 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 

暗示脚本值尚未分配给变量。

4

1 回答 1

3

我猜你应该使用$(shell ...)函数来初始化月份变量:

month :=     $(shell $(R_HOME)/bin/Rscript ./R/reportperiod.R)
于 2013-02-18T21:57:55.357 回答