Knit2html不复制R Studio中的Knit HTML按钮功能 [英] Knit2html not replicating functionality of Knit HTML button in R Studio

查看:37
本文介绍了Knit2html不复制R Studio中的Knit HTML按钮功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Ubuntu 10.04中编写一个Bash脚本,该脚本将打开一个导出CSV的Python文件,然后运行以下Rscript,目的是从Dashboard.Rmd中导出带有绘图的HTML:

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:

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

Dashboard.Rmd是一个R降价标记,它从第一步开始在csv上调用read.csv,制作一个数据框并创建绘图,但是那部分工作正常.根据

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. According to this, I figure that Rscript should replicate the action of pressing "Knit HTML" in R Studio. However, the html it creates is identical to the last time Knit HTML was pressed; i.e. even if the CSV is different, the html doesn't reflect the change.

我还尝试对knit和markdownToHTML使用单独的一行,效果相同.似乎在执行编织时未从Rmd中获取代码.当我在打开Dashboard.Rmd的情况下将Rscript中的命令输入到R Studio的控制台中时,它会正确地更新html.但是我不确定如何将其转换为Bash脚本.我也尝试了knit2html和envir = new.env(),envir = R_GlobalEnv和envir = parent.frame()的运气.任何帮助将不胜感激!

I also tried using a separate line for knit and markdownToHTML with the same effect. It seems like it doesn't source the code from the Rmd when performing knit. It does update the html properly when I enter the commands from that Rscript into the console of R Studio with Dashboard.Rmd open. However I'm not sure how to translate that into a Bash script. I also tried knit2html with envir=new.env(), envir=R_GlobalEnv, and envir=parent.frame() with no luck. Any help would be appreciated!

推荐答案

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

So it turns out that this was an artifact of cache=TRUE -- the HTML file was not changed because everything was cached.

这篇关于Knit2html不复制R Studio中的Knit HTML按钮功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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