无法编译Rmarkdown文档 [英] Cannot compile Rmarkdown document
问题描述
我很难让我的R markdown文档得到编译和执行.在分析中,我进行了单向,双向ANOVA和ANCOVA分析以及许多绘图.
I have a very difficult time to get my R markdown document compiled and execute. I have one-way, two-way ANOVA and ANCOVA analyses in the analysis along with many plots.
这是尚未成功执行的第一个R代码块.
Here is the first R code chunk yet to be successfully executed.
{r, echo=FALSE}
install.packages("rmarkdown")
library(rmarkdown)
install.packages("knitr")
library(knitr)
install.packages("ggplot2")
install.packages("car")
library(car)
install.packages("pastecs")
library(pastecs)
install.packages("compute.es")
library(compute.es)
install.packes("multcomp")
library(multcopm)
install.packes("WRS2")
library(WRS2)
install.packages("gmodels")
library(gmodels)
install.packes("MASS")
library(MASS)
从30-60行退出(PPC.Rmd)contrib.url(repos, 源"):尝试在不设置镜像的情况下使用CRAN调用: ... withVisible-> eval-> eval-> install.packages-> contrib.url
Quitting from lines 30-60 (PPC.Rmd) Error in contrib.url(repos, "source") : trying to use CRAN without setting a mirror Calls: ... withVisible -> eval -> eval -> install.packages -> contrib.url
执行停止
推荐答案
我通常会携带一些小功能
I usually carry small function
check_and_install <- function( packname ) { # given package name, check installation, install if not found
if ( packname %in% rownames(installed.packages()) == FALSE ) {
install.packages( packname )
}
}
所以在Rmd开始时我就做
so at the beginning of the Rmd i do
check_and_install("ggplot2")
library(ggplot2)
....
这篇关于无法编译Rmarkdown文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!