Failed with error: ‘packages could not be loaded’ - r

Executing the script below is generating an error that did not occur before.
Here's my code:
Pacotes <- c("MethComp","qqplotr","imputeTS","multiway","prettydoc","moments",
"mclust","ggQC","stats","ffp","RVAideMemoire","forecast","AID",
"ggplot2","nortest","rmarkdown","gt","MASS","plotly","ggpubr",
"readxl","calibrate","mixtools","knitr","kableExtra","modeest",
"dplyr","cluster","factoextra","FactoMineR","DT","cartography",
"data.table","devtools","univOutl","multimode","mixR",
"refineR","KernSmooth")
if(sum(as.numeric(!Pacotes %in% installed.packages())) != 0){
instalador <- Pacotes[!Pacotes %in% installed.packages()]
for(i in 1:length(instalador)) {
install.packages(instalador, dependencies = TRUE)
break()}
sapply(Pacotes, require, character = TRUE)
} else {
sapply(Pacotes, require, character = TRUE)
}
Failed with error: 'package ‘ggplot2’ could not be loaded'
Failed with error: 'package ‘ggplot2’ could not be loaded'
Failed with error: 'package ‘ggplot2’ could not be loaded'
Failed with error: 'package ‘ggplot2’ could not be loaded'
Failed with error: 'package ‘usethis’ could not be loaded'
Failed with error: 'package ‘ggplot2’ could not be loaded'
Can anybody help me? Why is this error occurring?
The error started to occur after installing the latest version of R and RStudio on my notebook that has the Windows 10 Pro operating system.

Related

How Do I resolve issues with DMRcate, bumphunter & CURL_OPENSSL_3?

I am trying to load a library - specifically DMRcate and there seem to be several issues that pop up and I am unsure as to how to resolve these issues.
First I tried: to simply load the library for DMRcate
library(DMRcate)
however, I got the following error message:
Loading required package: minfi
Loading required package: bumphunter
Error: package or namespace load failed for ‘bumphunter’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object 'filepath/Rsamtools.so':
filepath/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by filepath/Rsamtools.so)
Error: package ‘bumphunter’ could not be loaded
Traceback:
1. library(DMRcate)
2. .getRequiredPackages2(pkgInfo, quietly = quietly)
3. library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc,
. quietly = quietly)
4. .getRequiredPackages2(pkgInfo, quietly = quietly)
5. stop(gettextf("package %s could not be loaded", sQuote(pkg)),
. call. = FALSE, domain = NA)
then I simply tried to get around by adding the bumphunter library to the beginning section of code:
library(DMRcate)
library(bumphunter)
however this error message pops up:
Loading required package: minfi
Loading required package: bumphunter
Error: package or namespace load failed for ‘bumphunter’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object 'filepath/Rsamtools.so':
filepath/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by filepath/Rsamtools.so)
Error: package ‘bumphunter’ could not be loaded
Traceback:
1. library(DMRcate)
2. .getRequiredPackages2(pkgInfo, quietly = quietly)
3. library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc,
. quietly = quietly)
4. .getRequiredPackages2(pkgInfo, quietly = quietly)
5. stop(gettextf("package %s could not be loaded", sQuote(pkg)),
. call. = FALSE, domain = NA)
I am not sure what I am doing wrong? I am using a cluster and I cannot use sudo or apt-get as this isn't allowed. I am using a Mac Air M2. Could anyone help me to know what is wrong with the code I have written?
I then tried to install the packages itself in Jupyter notebooks:
if (!require("BiocManager"))
install.packages("BiocManager")
BiocManager::install("bumphunter")
But then the error was odd
Error: Bioconductor version cannot be validated; no internet connection?
Traceback:
1. BiocManager::install("bumphunter")
2. .version_validate(version)
3. ifelse(.is_CRAN_check(), .message(txt), .stop(txt))
4. .stop(txt)
5. stop(.msg(...), call. = call.)
I am connected to the internet, and the HPC and on site. What am I doing wrong?

Can't install the ggplot2 package

I am trying to install the ggplot2 package I am getting the following errors & warnings.
Warning: failed to download mirrors file (cannot open URL 'https://cran.r-project.org/CRAN_mirrors.csv'); using local file 'C:/PROGRA~1/R/R-42~1.1/doc/CRAN_mirrors.csv'
Error in contrib.url(repos, type) :
trying to use CRAN without setting a mirror
In addition: Warning message:
In download.file(url, destfile = f, quiet = TRUE) :
URL 'https://cran.r-project.org/CRAN_mirrors.csv': status was 'Couldn't connect to server'
> utils:::menuInstallPkgs()
--- Please select a CRAN mirror for use in this session ---
Warning: failed to download mirrors file (cannot open URL 'https://cran.r-project.org/CRAN_mirrors.csv'); using local file 'C:/PROGRA~1/R/R-42~1.1/doc/CRAN_mirrors.csv'
Warning: unable to access index for repository https://repo.miserver.it.umich.edu/cran/src/contrib:
cannot open URL 'https://repo.miserver.it.umich.edu/cran/src/contrib/PACKAGES'
Error in install.packages(lib = .libPaths()[1L], dependencies = NA, type = type) :
argument "pkgs" is missing, with no default
In addition: Warning message:
In download.file(url, destfile = f, quiet = TRUE) :
URL 'https://cran.r-project.org/CRAN_mirrors.csv': status was 'SSL connect error'
> utils:::menuInstallPkgs()
Warning: unable to access index for repository https://repo.miserver.it.umich.edu/cran/src/contrib:
cannot open URL 'https://repo.miserver.it.umich.edu/cran/src/contrib/PACKAGES'
Error in install.packages(lib = .libPaths()[1L], dependencies = NA, type = type) :
argument "pkgs" is missing, with no default
> utils:::menuInstallPkgs()
Warning: unable to access index for repository https://repo.miserver.it.umich.edu/cran/src/contrib:
cannot open URL 'https://repo.miserver.it.umich.edu/cran/src/contrib/PACKAGES'
Error in install.packages(lib = .libPaths()[1L], dependencies = NA, type = type) :
argument "pkgs" is missing, with no default
> utils:::menuInstallPkgs()
Warning: unable to access index for repository https://repo.miserver.it.umich.edu/cran/src/contrib:
cannot open URL 'https://repo.miserver.it.umich.edu/cran/src/contrib/PACKAGES'
Error in install.packages(lib = .libPaths()[1L], dependencies = NA, type = type) :
argument "pkgs" is missing, with no default
> utils:::menuInstallLocal()
> utils:::menuInstallLocal()
Error in utils:::menuInstallLocal() :
Only '*.zip' and '*.tar.gz' files can be installed.
> utils:::menuInstallLocal()
ERROR: dependencies 'digest', 'glue', 'gtable', 'isoband', 'rlang', 'scales', 'tibble', 'withr' are not available for package 'ggplot2'
* removing 'C:/Users/S/AppData/Local/R/win-library/4.2/ggplot2'
Warning message:
In install.packages(files[tarballs], .libPaths()[1L], repos = NULL, :
installation of package ‘C:/Users/S/Documents/ggplot2_3.3.6.tar.gz’ had non-zero exit status
> utils:::menuInstallPkgs()
Warning: unable to access index for repository https://repo.miserver.it.umich.edu/cran/src/contrib:
cannot open URL 'https://repo.miserver.it.umich.edu/cran/src/contrib/PACKAGES'
Error in install.packages(lib = .libPaths()[1L], dependencies = NA, type = type) :
argument "pkgs" is missing, with no default

Unable to Install devtools in R on Jenkins

I'm building a Jenkins Job to test a library.
I'm doing most of the scripts work in the r-base docker image.
When I try to install dev tools via Rscript -e
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE) # create personal library
.libPaths(Sys.getenv("R_LIBS_USER")) # add to the path
install.packages("devtools")
install_allstate_github <- function(user, repo, ...) {
tmp_dir <- "$app_dir/ravenclaw"
devtools::install(tmp_dir, dependencies = TRUE)
}
install_allstate_github("SortingHat", "ravenclaw")
library(ravenclaw)
I get the following error
Warning message:
In dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE) :
'/export/home/compjenk/workspace/ISG-Sorting-Hat/Ravenclaw/r-libs' already exists
Installing package into ���/export/home/compjenk/workspace/ISG-Sorting-Hat/Ravenclaw/r-libs���
(as ���lib��� is unspecified)
Warning: unable to access index for repository https://****:****#artifactory.allstate.com/artifactory/cran/src/contrib:
cannot open URL 'https://****:****#artifactory.allstate.com/artifactory/cran/src/contrib/PACKAGES'
Warning messages:
1: In gzfile(file, "rb") :
cannot open compressed file '/tmp/RtmpQGoABw/repos_https://****:****#artifactory.allstate.com/artifactory/cran/src/contrib.rds', probable reason 'No such file or directory'
2: package ���devtools��� is not available (for R version 4.0.2)
Error in loadNamespace(name) : there is no package called ���devtools���
Calls: install_allstate_github ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
I've set the corporate CRAN server in .Rprofile as well as Proxy information but it doesn't seem to help.
.Rprofile
local({
r <- list("cran" = "https://****:****#artifactory.allstate.com/artifactory/cran/")
options(repos = r)
options(RCurlOptions = list(ssl.verifypeer = FALSE,
ssl.verify = FALSE,
proxy = "http://webproxy:8080"))
#set_config( config( ssl_verifypeer = 0L ) )
Sys.setenv(http_proxy = "http://webproxy:8080")
Sys.setenv(https_proxy = "https://webproxy:8080")
So What am I missing or doing wrong? why can't I install devTools?

How to downgrade an installed package version?

I'm trying to downgrade the package version of officer that I have from the most recent (v 0.3.12) to v 0.3.8.
I tried running the below lines, all of which failed:
What am I doing wrong?
require(devtools)
install_version("officer", version = "0.3.8")
---Error: Failed to install 'unknown package' from URL:
(converted from warning) package ‘officer’ is in use and will not be installed
require(devtools)
install_version("officer", version = "0.3.8", repos = "https://cran.r-project.org/web/packages/officer/index.html")
--- cannot open URL 'https://cran.r-project.org/web/packages/officer/index.html/src/contrib/PACKAGES'
Error in package_find_repo(package, repos) :
could not find package 'officer'
require(devtools)
install_version("officer", version = "0.3.8", repos = "https://davidgohel.github.io/officer/")
--- cannot open URL 'https://davidgohel.github.io/officer/src/contrib/PACKAGES'
Error in package_find_repo(package, repos) :
could not find package 'officer'
library(devtools)
devtools::install_github(davidgohel/officer, ref = "officer_0.3.8")
---Error in lapply(repo, github_remote, ref = ref, subdir = subdir, auth_token = auth_token, :
object 'davidgohel' not found
devtools::install_github("davidgohel/officer", ref = "0.3.8")
---Error in utils::download.file(url, path, method = method, quiet = quiet, :
cannot open URL 'https://api.github.com/repos/davidgohel/officer/tarball/0.3.8

Error when installing quantmod in r

I am Trying to install "quantmod" in R but I can't manage. I tried unistalling and installing R again, and updating to the lastest version. I use windows. I get the following errors:
> library(quantmod)
Loading required package: TTR
Error: package or namespace load failed for ‘TTR’ in namespaceExport(ns, exports):
undefined exports: curl, curl_download, curl_echo, curl_escape, curl_fetch_disk, curl_fetch_memory, curl_fetch_multi, curl_fetch_stream, curl_options, curl_unescape, curl_version, form_data, form_file, handle_cookies, handle_data, handle_reset, handle_setform, handle_setheaders, handle_setopt, has_internet, ie_get_proxy_for_url, ie_proxy_info, multi_add, multi_cancel, multi_list, multi_run, multi_set, new_handle, new_pool, nslookup, parse_date, parse_headers
Error: package ‘TTR’ could not be loaded
In addition: Warning message:
S3 methods ‘print.curl_handle’, ‘print.curl_multi’, ‘print.form_data’, ‘print.form_file’ were declared in NAMESPACE but not found
When trying to install TTR:
> library(TTR)
Error: package or namespace load failed for ‘TTR’ in namespaceExport(ns, exports):
undefined exports: curl, curl_download, curl_echo, curl_escape, curl_fetch_disk, curl_fetch_memory, curl_fetch_multi, curl_fetch_stream, curl_options, curl_unescape, curl_version, form_data, form_file, handle_cookies, handle_data, handle_reset, handle_setform, handle_setheaders, handle_setopt, has_internet, ie_get_proxy_for_url, ie_proxy_info, multi_add, multi_cancel, multi_list, multi_run, multi_set, new_handle, new_pool, nslookup, parse_date, parse_headers
In addition: Warning message:
S3 methods ‘print.curl_handle’, ‘print.curl_multi’, ‘print.form_data’, ‘print.form_file’ were declared in NAMESPACE but not found
PF: I get a similar error when trying to execute the "forecast" package
> library(forecast)
Error: package or namespace load failed for ‘forecast’ in namespaceExport(ns, exports):
undefined exports: curl, curl_download, curl_echo, curl_escape, curl_fetch_disk, curl_fetch_memory, curl_fetch_multi, curl_fetch_stream, curl_options, curl_unescape, curl_version, form_data, form_file, handle_cookies, handle_data, handle_reset, handle_setform, handle_setheaders, handle_setopt, has_internet, ie_get_proxy_for_url, ie_proxy_info, multi_add, multi_cancel, multi_list, multi_run, multi_set, new_handle, new_pool, nslookup, parse_date, parse_headers
In addition: Warning message:
S3 methods ‘print.curl_handle’, ‘print.curl_multi’, ‘print.form_data’, ‘print.form_file’ were declared in NAMESPACE but not found
Linux terminal:
sudo apt-get install libcurl4-openssl-dev
R console:
install.packages("quantmod")

Resources