如何在交互式会话中读取knitr/Rmd缓存? [英] How to read knitr/Rmd cache in interactive session?

查看:474
本文介绍了如何在交互式会话中读取knitr/Rmd缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Rmd文件,其中包含许多缓存的代码块.

I have an Rmd file with a lot of cached code chunks.

现在,我想继续使用交互式会话来开发该脚本,以便在将最终代码放入文档的新块之前试用并测试不同的解决方案.

Now I want to keep developing that script using an interactive session to play around and test different solutions before putting the final code in a new chunk of the document.

使用普通的R脚本,我可以直接获取它,以使我的交互式会话与脚本的最后一行保持一致. 但是,这将导致(重新)执行交互式会话中的所有代码.

With a plain R script, I could just source it to get my interactive session on par with the last line of the script. However, this would result in (re-)executing all code within the interactive session.

我想将我的Rmd文件读入交互式会话,而忽略Markdown部分&利用现有的knitr缓存,理想情况下不创建任何输出.

I want to read my Rmd file into an interactive session ignoring the Markdown part & making use of the existing knitr cache, ideally without creating any output.

我该怎么做?

PS:我不是在寻找某种特定于IDE的方法来进行此设置,而是在寻找可以从任何终端仿真器中的简单R会话运行的命令.

PS: I am not looking for some IDE-specific way to set this up but for a command that I can run from a simple R session in any terminal emulator.

推荐答案

认为在控制台/R会话中运行library("knitr"); knit("foo.Rmd")是最简单的方法,尽管它将重写foo.md,数字等.(太忙/懒惰,无法对其进行测试.)

I think that running library("knitr"); knit("foo.Rmd") in the console/R session is the easiest way to do this, although it will rewrite foo.md, figures, etc.. (Too busy/lazy to test it at the moment.)

您可能会在cache目录中四处浏览并直接读取缓存的文件,但这会花费更多的工作/精力.

You could probably poke around in the cache directory and read the cached files directly, but that would be a lot more work/trickier.

这篇关于如何在交互式会话中读取knitr/Rmd缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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