简体   繁体   English

R knitr:是否可以在不同的计算机上使用缓存的结果?

[英]R knitr: is it possible to use cached results across different machines?

Issue solved , see answers for details. 问题已解决 ,请参阅答案以获取详细信息。

I would like to run some code (with knitr ) on a more powerful server and then maybe have the possibility of making small changes on my own laptop. 我想在功能更强大的服务器上运行一些代码(使用knitr ),然后可能在自己的笔记本电脑上进行一些小的更改。 Even copying across the entire folder, it seems that the cache is rebuilt when re-compiling locally, is there a way to avoid that and actually use the results in the cache? 即使在整个文件夹中复制,似乎在本地重新编译时也会重建缓存,有没有办法避免这种情况并在缓存中实际使用结果?

Update: the problem arose from different versions of knitr on different machines. 更新:问题来自不同机器上的不同版本的knitr


In theory, yes -- if you do not change anything, the cache will be kept. 从理论上讲,是的-如果您不进行任何更改,则将保留缓存。 In practice, you have to check carefully what the "small changes" are. 在实践中,您必须仔细检查什么是“小变化”。 The documentation page for cache has explained when the cache will be rebuilt, and you need to check if all three conditions are met. 缓存的文档页面已经说明了何时重建缓存,并且您需要检查是否满足所有三个条件。

I wonder if in addition to @Yihui's answer if the process of copying from one machine to another changes the datetimes on the files so that they look out of date even when nothing has changed. 我想知道,除了@Yihui的答案之外,从一台计算机复制到另一台计算机的过程是否还会更改文件上的日期时间,以便即使没有任何更改也看起来过时。

Look at the dates on the files involved after copying. 复制后查看所涉及文件的日期。 If you can figure out which files need to be newer than others then touch ing them may prevent the rebuilding. 如果您可以确定哪些文件需要比其他文件更新,则touch它们可能会阻止重建。

Another option would be to just paste in the chached pieces directly so that they are not rerun (though that means you have to rerun and repaste manually if you change anything in those parts). 另一种选择是直接粘贴已粘贴的部分,以使它们不会重新运行(尽管这意味着如果您更改了这些部分中的任何内容,则必须手动重新运行并重新粘贴)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM