我正在尝试获取R ->文档工作流。我使用了here提供的教程。设置R系统的命令(我在本教程中使用过)是:
install.packages('pander')
library(knitr)
knit2html("example.rmd")
# installing/loading the package:
if(!require(installr)) { install.packages("installr"); require(installr)} #load / install+load installr
# Installing pandoc
install.pandoc()
FILE <- "example"
system(paste0("pandoc -o ", FILE, ".docx ", FILE, ".md"))来自站点(example.rmd)的示例文件是:
Doc header 1
============
```{r set_knitr_chunk_options}opts_chunk$set(echo=FALSE,message=FALSE,results = "asis") #确保输出格式正确的重要信息。
```{r load_pander_methods}需要(搜索器)
函数<- replace.print.methods (PKG_name= "pander") {
PKG_methods <- as.character(methods(PKG_name))
打印<- gsub(PKG_name,“print_methods”,PKG_methods)
对于(i in seq_along(PKG_methods)) {
f <- eval(parse(text=paste(PKG_name,":::", PKG_methods[i], sep = ""))) # the new function to use for print assign(print_methods[i], f, ".GlobalEnv")}
}
replace.print.methods()
以下操作可能适用于某些调整:
print <- function (x,...)UseMethod("pander")
Some text explaining the analysis we are doing
```{r}摘要(汽车)#一个汇总表
拟合<- lm(距离~速度,数据=汽车)
适合
plot(cars) #a图
这将创建一个如下所示的doc文件(末尾也有一个图表):
Doc header 1
opts_chunk$set(echo = FALSE, message = FALSE, results = "asis") # important for making sure the output will be well formatted.
## Warning: there is no package called 'pander'
## Error: no function 'pander' is visible
Some text explaining the analysis we are doing speed dist
Min. : 4.0 Min. : 2
1st Qu.:12.0 1st Qu.: 26
Median :15.0 Median : 36
Mean :15.4 Mean : 43
3rd Qu.:19.0 3rd Qu.: 56
Max. :25.0 Max. :120
Call: lm(formula = dist ~ speed, data = cars)
Coefficients: (Intercept) speed
-17.58 3.93
![generated graph image][1]现在,我如何删除生成的doc文件中的错误?如果可能的话,我想解决这些错误。
发布于 2013-10-10 06:02:28
pander不是knitr。
您将需要安装pander包。(即install.packages('pander')),就像您安装knitr一样。
https://stackoverflow.com/questions/19283485
复制相似问题