Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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)

....

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...