运行Makefile,但最后一个文件被跳过 - R [英] Running Makefile but the last file is skipped - R

查看:120
本文介绍了运行Makefile,但最后一个文件被跳过 - R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许我在这里做了一些非常愚蠢的事情,但我确实无法发现我的错误。这里是Makefile:

  R_OPTS =  -  no-save --no-restore --no-init-file  - no-site-file 

data / clean_data.RData:R / 0_clean.R data / raw_data.dta
cd R; Rscript 0_clean.R $(R_OPTS)

fig / ttest_result.pdf:R / 1_1_ttest_result.R data / clean_data.RData
cd R; Rscript 1_1_ttest_result.R $(R_OPTS)

只有 raw_data.dta ,如果我运行 make ,则 clean_data.RData 已创建,但 ttest_result.pdf 不是。但是,当我明确运行 make fig / ttest_result.pdf 时,会创建该文件。我真的失去了为什么?



额外信息: 1_1_ttest_result.R 正在创建 ttest_result.pdf with ggplot2 using ggsave()

解决方案

运行没有目标的make文件时的默认设置就是构建第一个目标。在这种情况下,这只是data / clean_data.RDat,因此这是唯一将被创建的文件。这就是为什么你经常看到makefile这样的原因:

  R_OPTS =  -  no-save --no-restore --no-init-file --no-site-file 

all:data / clean_data.RData fig / ttest_result.pdf

data / clean_data.RData:R / 0_clean.R data / raw_data。 dta
cd R; Rscript 0_clean.R $(R_OPTS)

fig / ttest_result.pdf:R / 1_1_ttest_result.R data / clean_data.RData
cd R; Rscript 1_1_ttest_result。 R $(R_OPTS)

所以第一个目标列出了默认情况下你想建立的所有东西。


Maybe I am doing something very stupid here, but I really can't spot my mistake. Here is the Makefile:

R_OPTS=--no-save --no-restore --no-init-file --no-site-file

data/clean_data.RData: R/0_clean.R data/raw_data.dta
    cd R;Rscript 0_clean.R $(R_OPTS)

fig/ttest_result.pdf: R/1_1_ttest_result.R data/clean_data.RData   
    cd R;Rscript 1_1_ttest_result.R $(R_OPTS)

With only raw_data.dta, if I run make, the clean_data.RData is created but ttest_result.pdf is not. However, when I run make fig/ttest_result.pdf explicitly, the file is created. I'm really lost about why?

Extra info: 1_1_ttest_result.R is creating ttest_result.pdf with ggplot2 using ggsave()

解决方案

The default when you run a make file with no target is just to build the first target. In this case, that's only "data/clean_data.RDat" so that's the only file that will get created. That's why you often see makefiles like

R_OPTS=--no-save --no-restore --no-init-file --no-site-file

all: data/clean_data.RData fig/ttest_result.pdf

data/clean_data.RData: R/0_clean.R data/raw_data.dta
    cd R;Rscript 0_clean.R $(R_OPTS)

fig/ttest_result.pdf: R/1_1_ttest_result.R data/clean_data.RData   
    cd R;Rscript 1_1_ttest_result.R $(R_OPTS)

so the first target lists everything you want to build by default.

这篇关于运行Makefile,但最后一个文件被跳过 - R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆