Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
228 views
in Technique[技术] by (71.8m points)

r - Cannot compile Rmarkdown document

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.

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)

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

Execution halted

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 )
    }
}

so at the beginning of the Rmd i do

check_and_install("ggplot2")
library(ggplot2)

....

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...