Execute R Script install.packages gives error: cannot open URL 'http://cran.us.r-project.org/src/contrib/PACKAGES'

Eade, Jeremy 26 Reputation points
2021-08-03T21:14:30.273+00:00

Hi, I'm trying to install the NbClust R package from an Execute R Script block in Designer:

Code:

azureml_main <- function(dataframe1, dataframe2){

  # Install required libraries
  print("**** START: Installing required libraries ****")

  install.packages("NbClust",repos = "http://cran.us.r-project.org")  
  library(NbClust)

  print("**** END: Installing required libraries ****") 

  print("R script run.")

  print(summary(dataframe1))

  # If a zip file is connected to the third input port, it is
  # unzipped under "./Script Bundle". This directory is added
  # to sys.path.

  # Return datasets as a Named List
  return(list(dataset1=dataframe1, dataset2=dataframe2))
}

Error:

[1] "R script run."
[1] "Import packages."
Loading required package: reticulate
Loading required package: jsonlite
Loading required package: dplyr

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

filter, lag

The following objects are masked from ‘package:base’:

intersect, setdiff, setequal, union

[1] "R read input parquet file."
[1] "0 columns have been set to origin types."
[1] "**** START: Installing required libraries ****"
Warning: unable to access index for repository http://cran.us.r-project.org/src/contrib:
cannot open URL 'http://cran.us.r-project.org/src/contrib/PACKAGES'
Error in library(NbClust) : there is no package called ‘NbClust’
Calls: tryCatch ... tryCatchList -> withCallingHandlers -> azureml_main -> library
In addition: Warning message:
package ‘NbClust’ is not available (for R version 3.5.1)
Execution halted

The same "install.packages("NbClust",repos = "http://cran.us.r-project.org")
library(NbClust)" R code works just fine on my local computer.

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,235 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. GiftA-MSFT 11,176 Reputation points
    2021-08-04T22:03:53.72+00:00

    Hi, I wasn't able to reproduce this issue in Designer, are you still unable to install the R package?

    downloaded 21 KB
    
    * installing *source* package ‘NbClust’ ...
    ** package ‘NbClust’ successfully unpacked and MD5 sums checked
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded
    * DONE (NbClust)
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.