Fehler in contrib.url(repos,"source"): trying to use CRAN without setting a mirror

Hello!
I hope you can help me to solve my issue. I am really new at this topic, for that please excuse if I do something wrong in my question..

After I did some coding in RStudio within a R Script, I need to export my coding, results and comments as PDF. Therefore I used "Compile Report".

If I do so, I get the following error:

Fehler in contrib.url(repos, "source") : trying to use CRAN without setting a mirror Ruft auf: ... withVisible -> eval -> eval -> install.packages -> contrib.url Ausf├╝hrung angehalten

I already googled a lot to solve this issue but nothing works for me..

My R Code begins as follows:

install.packages("epiR")
library(epiR)
install.packages("moments")
library(moments)
install.packages("QuantPsyc")
library(QuantPsyc)
install.packages("psych")
library(psych)

#Importing the data as "PartA"
PartA <- library(readxl)
PartA <- read_excel("C:/Users//Kopie von sheet1_partA-2.xlsx",
na = "NA")

#Importing the data as "PartB"
PartB <- library(readxl)
PartB <- read_excel("C:/Users//sheet1_partB2.xlsx",
col_types = c("numeric", "numeric", "numeric"),
na = "NA")

I work with the following system:
RStudio, Version 1.3.959, Windows

If you can help me with this, I would be very delighted if you do this for beginners in an easy way..

Thank you!
Johanna

Do you mean you are using an .Rmd file and you want to knit the document to PDF?. I'm asking this because R scripts (.R) are not meant to be knitted and R is an interpreted language so there is no compiling involved, ergo it is not clear what are you referring to.

About your code, there are some evident issues:

You only have to install packages once so you shouldn't include install commands in your scripts, you only have to load them with library()

This line makes no sense, you cant assign a package to an object, so simply load the package (and you only have to do it once per R session so no need to repeat)

library(readxl)
PartA <- read_excel("C:/Users//Kopie von sheet1_partA-2.xlsx", na = "NA")
PartB <- read_excel("C:/Users//sheet1_partB2.xlsx",
col_types = c("numeric", "numeric", "numeric"),
na = "NA")

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.