Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
knitr';s缓存机制检查是否运行块?_R_Caching_Knitr - Fatal编程技术网

knitr';s缓存机制检查是否运行块?

knitr';s缓存机制检查是否运行块?,r,caching,knitr,R,Caching,Knitr,我正在用knitr和Latex编写文档,缓存机制有问题。具体来说,我有一个问题,就是我将多个数据帧写入CSV文件,以便稍后使用pgfplotstable读取它们。但是,如果相应的CSV文件已被删除或以任何方式更改,knitr的缓存机制将无法重新运行块。例如,运行以下文档一次,删除mwe.dat,然后再次运行将产生错误 \documentclass{article} \begin{document} <<cache=TRUE>>= df <- data.frame(a

我正在用
knitr
Latex
编写文档,缓存机制有问题。具体来说,我有一个问题,就是我将多个数据帧写入CSV文件,以便稍后使用
pgfplotstable
读取它们。但是,如果相应的CSV文件已被删除或以任何方式更改,knitr的缓存机制将无法重新运行块。例如,运行以下文档一次,删除
mwe.dat
,然后再次运行将产生错误

\documentclass{article}
\begin{document}
<<cache=TRUE>>=
df <- data.frame(a=rep(1,5), b=rep(2.5), c=rep(3,5))
write.csv(df, file='mwe.dat')
rm(df)
@

<<cache=FALSE>>=
df <- read.csv(file='mwe.dat')
## Warning: cannot open file ’mwe.dat’: No such file or directory
## Error: cannot open the connection
@
\end{document}
\documentclass{article}
\开始{document}
=
df在
knitr
网站上解释了这个问题。特别是,在该页面中搜索类似情况的
#238

从该链接:问题#238显示了该选项的另一个良好用途:缓存与文件修改时间相关联,即当数据文件被修改时,缓存将自动重建。