Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Data Science
  3. Question
Data Science

R error in contrib.url(repos source )

Asked by Jan Ferguson Jul 12, 2021 4.4K views 1 answer
Share

About this question

 I am using shell commands to install some packages in R.  I have an R file "installDependencies.R" for installing packages, this is the content of the file:
packages <- c("xts","stringr","log4r")
# Function to check whether package is installed
is.installed <- function(mypkg){
  is.element(mypkg, installed.packages()[,1])
}
for(package in packages){
  # check if package is installed
  if (!is.installed(package)){
    install.packages(package)
  }
}

Next, I'm running this on the terminal. This is the shell script I created:

#!/bin/bash
Rscript installDependencies.R
I get the following error while running the file:
algotree@algotree-900X3C-900X4C-900X4D:~$ ./inst.sh
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)

Error in contrib.url(repos, type) : 

  trying to use CRAN without setting a mirror

Calls: install.packages -> grep -> contrib.url

Execution halted

algotree@algotree-900X3C-900X4C-900X4D:~$ 

Your answer

1 Answer

More Data Science discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Data Science Blogs

Guides, tips and career advice on Data Science from JanBask experts.