有没有一种方法可以使用RStudio直接在您的工作空间中进行降价促销? [英] Is there a way to knitr markdown straight out of your workspace using RStudio?

查看:99
本文介绍了有没有一种方法可以使用RStudio直接在您的工作空间中进行降价促销?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以使用knitr降价功能仅使用当前工作空间中的对象动态创建报告.可重复性不是这里的问题.我也阅读了很好的这里的线程 .

I wonder whether I can use knitr markdown to just create a report on the fly with objects stemming from my current workspace. Reproducibility is not the issue here. I also read this very fine thread here.

但是我仍然收到一条错误消息,抱怨找不到特定的对象.

But still I get an error message complaining that the particular object could not be found.

1)假设我打开了一个新的降价文档并保存了.

1) Suppose I open a fresh markdown document and save it.

2)编写一个块,该块引用我的工作空间中的某些lm对象.致电summary(mylmobject)

2) write a chunk that refers to some lm object in my workspace. call summary(mylmobject)

3)编织它.

不幸的是,生成了报告,但是由于找不到对象,因此无法显示回归输出.请注意,如果我只是将对象保存到.Rdata,然后直接从markdown文件中加载它,则它通常可以正常工作.

Unfortunately the report is generated but the regression output cannot be shown because the object could not be found. Note, it works in general if i just save the object to .Rdata and then load it directly from the markdown file.

有没有一种方法可以使用当前工作空间中R降价的对象? 向非R人员显示一些仍在工作的输出,这真是太好了.

Is there a way to use objects in R markdown that are in the current workspace? This would be really nice to show non R people some output while still working.

推荐答案

RStudio为knit()您的R Markdown文件打开一个 new R会话,因此当前工作空间中的对象将不会可用于该会话(它们是两个单独的会话).两种解决方案:

RStudio opens a new R session to knit() your R Markdown file, so the objects in your current working space will not be available to that session (they are two separate sessions). Two solutions:

  1. 向RStudio提交功能请求,要求他们在当前R中支持编织会话,而不是强制开始新的会话;
  2. 自己手工编织:library(knitr); knit('your_file.Rmd')(如果要一步输出HTML,则为knit2html(),如果使用rmarkdown::render())rel = "noreferrer"> R Markdown v2 )
  1. file a feature request to RStudio, asking them to support knitting in the current R session instead of forcibly starting a new session;
  2. knit manually by yourself: library(knitr); knit('your_file.Rmd') (or knit2html() if you want HTML output in one step, or rmarkdown::render() if you are using R Markdown v2)

这篇关于有没有一种方法可以使用RStudio直接在您的工作空间中进行降价促销?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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