gpt4 book ai didi

r - 将 RScript 的输出分配给 makefile 变量

转载 作者:行者123 更新时间:2023-12-02 00:11:42 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com