nba2020
nba2020

Reputation: 708

R schedule automatic package updates

I want to automatically check and update packages every day. For this purpose, I've written few lines below which runs smoothly when I execute it in my RStudio.

options(install.packages.compile.from.source = "always")
update.packages(ask = FALSE, dependencies = TRUE)

Then I scheduled this mini script with taskscheduleR package to run daily. The scheduled job is succesfully called to be executed but is being halted and logs the below error:

Error in contrib.url(repos, type) : 
  trying to use CRAN without setting a mirror
Calls: update.packages -> available.packages -> contrib.url
Execution halted

What do I need to add in order to make it execute?

Upvotes: 2

Views: 220

Answers (1)

JacobJacox
JacobJacox

Reputation: 947

add this to specify CRAN mirror:

options(repos = c(CRAN = "http://cran.rstudio.com"))

Does it work now?

Upvotes: 2

Related Questions