Problems with tidyverse and CRAN

Hey,
I have to use R Studio for my statistics course in uni. For my task I had to download tidy verse, everything went smoothly until I had to knit it to submit it. Now there is an error message shown. I google image reversed it and google gave me the code "options(repos = c(CRAN = "https://cran.rstudio.com/"))" is this the right one? Or what else should I try.
Here are the contents of the error:
Error in 'contrib.url()':
! trying to use CRAN without setting a mirror Backtrace:

  1. 'utils:: install packages("tidyverse")
  2. -utils:: contrib.url(repos, "source")
    thanks for any help in advance

Hi, welcome to the forum.

Can we assume you are producing an Rmarkdown document?

Is this statement within or outside the Rmarkdown document?

utils:: install packages("tidyverse")

What is this statement doing?

utils:: contrib.url(repos, "source")

Can you give us the YAML and R code you are using?
Copy the code and paste it here between

```

````

We, probably do not need any of the plain text in the document.

Hey thanks for the fast reply. This is the code I was using:

install.packages("tidyverse")
library("tidyverse")

Temperatur$Uhrzeit <- seq(from = as_datetime("2019_07_25 12:00:00"), to = as_datetime("2019_07_26 11:00:00"), by = "1 hour")

ggplot(Temperatur) +
geom_line(aes(x = Uhrzeit, y = innen), color = "blue", linewidth = 1) +
geom_line(aes(x = Uhrzeit, y = rand), color = "red", linewidth = 1) +
geom_line(aes(x = Uhrzeit, y = umland), color = "green", linewidth = 1) +
labs(x = "Zeit in h", y = "Temperatur in Grad Celsius", title = "Temperaturen München und Umland")
[/quote]

Yes the first Statement is within the Rmarkdown document. The second statement is from Google, when I google image reversed the error message so I don't know if it is correct or where it is from

Thanks.

Your first problem is than you cannot install a package within an RMarkdown document. You must install it at the normal operating level. You can only do

library("tidyverse")

within the document. By the way the "" are optional

library(tidyverse)

will work just as well.

You do not need

contrib.url(repos, "source")

It is not something you need in an ordinary R program or Rmarkdown document. It looks to me as if it is likely to cause problems, especially within an Rmarkdown document. Delete it.

Thank you a lot. Taking the code for installing the package out worked.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.