【发布时间】:2015-02-11 01:47:23
【问题描述】:
我想知道如何将 R 脚本转换为 HTML 报告(从听起来使用 knitr 是可行的方法)。如果可能,我想不使用使用 RStudio。
假设我必须遵循 R 脚本
#Load librarys + initilisation calculations
#User shouldn't see the next 2 lines
library(foo)
set.seed(42)
#User will see the next 3 lines
print("This is some text to describe what the user is about to see")
head(mtcars)
boxplot(mtcars$mpg~mtcars$cyl)
#Not shown to user:
numbers <- runif(100)
moreNumbers <- rnorm(100)
group <- c(rep("a",100), rep("b",100))
df <- data.frame(c(numbers, moreNumbers), group)
names(df) <- c("ExampleData", "g")
#Show to user
t.test(df$ExampleData~df$g)
我试过浏览互联网,感觉好像所有步骤都比我理解的有点太远了。
我是否需要制作另一个 R 脚本,其中包含调用上述脚本的 stitch()/knit() 函数?
谢谢,
【问题讨论】:
-
你不需要 Rstudio 来使用 knitr。见rmarkdown.rstudio.com