简体   繁体   English

Knit2html不复制R Studio中的Knit HTML按钮功能

[英]Knit2html not replicating functionality of Knit HTML button in R Studio

I'm trying to write a Bash script in Ubuntu 10.04 that opens a Python file which exports a CSV, and then runs the following Rscript with the goal of exporting a HTML with plots from Dashboard.Rmd: 我试图在Ubuntu 10.04中编写一个Bash脚本,该脚本将打开一个导出CSV的Python文件,然后运行以下Rscript,目的是从Dashboard.Rmd中导出带有绘图的HTML:

require(knitr)
setwd('/home/sensors/Desktop/')
knit2html('Dashboard.Rmd')
browseURL('Dashboard.html')

Dashboard.Rmd is an R markdown that calls read.csv on the csv from the first step, makes a data frame and creates plots, but that part's working fine. Dashboard.Rmd是R降价,它从第一步开始在csv上调用read.csv,制作一个数据框并创建绘图,但是那部分工作正常。 According to this, I figure that Rscript should replicate the action of pressing "Knit HTML" in R Studio. 据此我认为Rscript应该复制R Studio中按下“编织HTML”的动作。 However, the html it creates is identical to the last time Knit HTML was pressed; 但是,它创建的html与上次按下Knit HTML时相同。 ie even if the CSV is different, the html doesn't reflect the change. 即,即使CSV不同,html也不反映更改。

I also tried using a separate line for knit and markdownToHTML with the same effect. 我还尝试对knit和markdownToHTML使用单独的一行,效果相同。 It seems like it doesn't source the code from the Rmd when performing knit. 似乎在执行编织时未从Rmd中获取代码。 It does update the html properly when I enter the commands from that Rscript into the console of R Studio with Dashboard.Rmd open. 当我在打开Dashboard.Rmd的情况下将Rscript中的命令输入R Studio的控制台时,它正确更新html。 However I'm not sure how to translate that into a Bash script. 但是我不确定如何将其转换为Bash脚本。 I also tried knit2html with envir=new.env(), envir=R_GlobalEnv, and envir=parent.frame() with no luck. 我也尝试了knit2html和envir = new.env(),envir = R_GlobalEnv和envir = parent.frame()的运气。 Any help would be appreciated! 任何帮助,将不胜感激!

因此,事实证明这是cache=TRUE的产物-HTML文件未更改,因为已缓存了所有内容。

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

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