我不知道如何让R识别Pander软件包
我正在尝试获得一个R->Docx工作流。我使用了给出的教程。设置R系统(我在教程中使用过)的命令有: 现在如何删除生成的文档文件中的错误?如果可能,我希望解决错误。不是我不知道如何让R识别Pander软件包,r,knitr,pandoc,pander,R,Knitr,Pandoc,Pander,我正在尝试获得一个R->Docx工作流。我使用了给出的教程。设置R系统(我在教程中使用过)的命令有: 现在如何删除生成的文档文件中的错误?如果可能,我希望解决错误。不是knitr 您需要安装pander软件包。(即,install.packages('pander'))正如您安装的knitr一样,我已经安装了该软件包。对不起,我忘了提那件事。我仍然有错误。您确定在load\u pander\u方法块中有require(pander)?在这种情况下,我无法复制您的问题(根据博客帖子),我不确定lo
knitr
您需要安装
pander
软件包。(即,install.packages('pander')
)正如您安装的knitr
一样,我已经安装了该软件包。对不起,我忘了提那件事。我仍然有错误。您确定在load\u pander\u方法
块中有require(pander)
?在这种情况下,我无法复制您的问题(根据博客帖子),我不确定load\u pander\u方法块在哪里。它位于/(应该位于)您试图编织的文件中(“example.rmd”
)……我编辑了问题以显示example.rmd文件。它有一个“需求(迎合者)”在里面。
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"))
Doc header 1
============
```{r set_knitr_chunk_options}
opts_chunk$set(echo=FALSE,message=FALSE,results = "asis") # important for making sure the output will be well formatted.
```
```{r load_pander_methods}
require(pander)
replace.print.methods <- function(PKG_name = "pander") {
PKG_methods <- as.character(methods(PKG_name))
print_methods <- gsub(PKG_name, "print", PKG_methods)
for(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()
## The following might work with some tweaks:
## print <- function (x, ...) UseMethod("pander")
```
Some text explaining the analysis we are doing
```{r}
summary(cars)# a summary table
fit <- lm(dist~speed, data = cars)
fit
plot(cars) # a plot
```
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]