Я запустил Spark
с AWS главного узла и попытался установить образец пакета с именем stringr
.
Вот команда - install.packages('stringr',repos = "http://cran.us.r-project.org", dependencies = TRUE)
Однако я получил это ошибка -
Installing package into "/usr/lib/spark/R/lib" (as ‘lib’ is unspecified) 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' Warning message: package ‘stringr’ is not available (for R version 3.4.1)
Вот мой фактический исходный код, где я пытаюсь установить необходимые пакеты -
# load Spark from within R code
.libPaths(c(file.path(Sys.getenv('SPARK_HOME') , 'R', 'lib'), .libPaths()))
library(SparkR)
sparkR.session()
# Function to install all the necessary packages needed for Markov model
install_neccessary_packages <- function(package_path,list_of_packages){
print("Dependency installation..")
# add package path to library paths
.libPaths(c(.libPaths(),package_path))
.libPaths()
# check which packages are needed to be installed
needed_packges <- setdiff(list_of_packages, rownames(installed.packages()))
# if packages are needed, then install them, load and proceed
# else, load the packages and proceed
if(length(needed_packges) > 0){
print("installing necessary packages...")
system('sudo yum -y install postgresql-devel')
system('sudo yum -y install curl-devel')
# install.packages(needed_packges,repos = "http://cran.us.r-project.org",lib=package_path, dependencies = TRUE)
install.packages(needed_packges,repos = "http://cran.us.r-project.org", dependencies = TRUE)
print("installation complete. Below packages are available for this session ::")
print(rownames(installed.packages()))
}else {
print("all needed packages are available. Below packages are available for this session ::")
print(rownames(installed.packages()))
}
print("end of function...")
} # end of function
package_path = "/home/demo/"
# get all the list of necessary packages
list_of_packages <- c("tidyverse","ChannelAttribution","gsubfn","stringr")
install_neccessary_packages(package_path,list_of_packages)