lib unspecified & Error in loadNamespace - r

I had everything working with R and RStudio, but then I moved the folders when cleaning up my computer directories & files. Now I'm getting the error message below.
Should R and RStudio be installed under Program Files or Program Files (x86)? Should I have two libPaths?
install.packages("C:/Users/kevin/Downloads/fpp_0.5.zip", repos = NULL)
## Warning in install.packages :
## package ‘C:/Users/kevin/Downloads/fpp_0.5.zip’
## is not available (for R version 3.0.0)
## Installing package into ‘C:/Users/kevin/Documents/R/win-library/3.0’
## (as ‘lib’ is unspecified)
## package ‘fpp’ successfully unpacked and MD5 sums checked
library("fpp", lib.loc="C:/Users/kevin/Documents/R/win-library/3.0")
Loading required package: forecast
## Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
## there is no package called ‘colorspace’
## Error: package ‘forecast’ could not be loaded

When you install the package using the RStudio package installer or directly from CRAN, it doesn't install the dependencies ("fracdiff", "Rcpp", "RcppArmadillo" and "colorspace") and hence, R keeps throwing the load namespace error. Installing the package through, automatically installs all the dependencies and solves this problem.
install.packages("forecast",
repos = c("http://rstudio.org/_packages",
"http://cran.rstudio.com"))

The last time I encountered a very similar problem, I used this code which I got somewhere:
install.packages("package's name", repos=c("http://rstudio.org/_packages", "http://cran.rstudio.com"))
simply put your package's name in the quotation marks.
Hope this helps.

Use this:
install.packages("colorspace", dependencies = TRUE)

I ran into this problem. It turned out that my .Rprofile had calls to a package that was not installed. Removing these lines allowed installation to proceed normally.

I got this error while installing the library 'tidyverse'. Removed the error by upgrading R from v3.4 to v3.6

Related

Truble loading 'Hmisc' [duplicate]

I'm unable to load the car package in R. I tried reinstalling using
install.packages("car",dependencies=TRUE)
both from R and RStudio. I tried installing quantreg as advised in another post and then installing it again. Installation appears to be successful, but simply can't load the program.
Here's the complete error:
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘pbkrtest’
In addition: Warning message: package ‘car’ was built under R version 3.2.3
Error: package or namespace load failed for ‘car’
This was just bumped to the homepage by Community. I can't take credit for the answer, but to give it a real non-comment answer:
You should upgrade R first. Then run update.packages(checkBuilt = TRUE). Finally, try again install.packages("car", dependencies=TRUE). If it doesn't work, try to install package pbkrtest first. - user3710546
Given that the current version of R at the time the question was posted was 3.2.3, I think that was a good answer.
I got the same error. (I am using R 3.2.2) Please perform the following steps in sequence (after that try to activate installed caret package):
install.packages("lme4", repos="http://cran.rstudio.com/",type = "binary", dependencies=TRUE)
install.packages("nlme", repos="http://cran.rstudio.com/",type = "binary", dependencies=TRUE)
packageurl <- "https://cran.r-project.org/src/contrib/Archive/pbkrtest/pbkrtest_0.4-4.tar.gz"
install.packages(packageurl, repos=NULL, type="source")
No need to upgrade R. I am still using R 3.2.2. I performed these steps and it worked for me.

Installing missing dependencies in an R package

I'm distributing an R package that requires other packages. If any are missing I get (for example) the following error:
library(whSample)
Error: package or namespace load failed for ‘whSample’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package called ‘dplyr’
I have code to check and install dependencies in the whSample package, but R fails before it gets to it when it sees the import(dplyr) in NAMESPACE. Here's the first block of code when the package function is called:
is_installed <- function(mypkg) is.element(mypkg, installed.packages()[,1])
whInstall <- function(pkgNames){
for(pkg in pkgNames){
if(!is_installed(pkg)){
install.packages(pkg, repos="http://lib.stat.cmu.edu/R/CRAN")
}
suppressMessages(suppressWarnings(
library(pkg, character.only=T, quietly=T, verbose=F)))
}
}
whInstall(c("magrittr","tools","purrr","openxlsx","data.table","dplyr","glue"))```
How can I get R to do these checks without running afoul of NAMESPACE?
A short answer is that you can ask people to install with
devtools::install_local("your-package.tar.gz")
What's happening behind the scene is that install.packages ignores the dependencies option when installing from a local file. It somehow assumes that the repository from which your are installing the package should also have the dependent packages. But for local files there is no repository, hence no dependency handling occurs.
When you install the package from a local file, install is going to search for dependencies on the same local path... and won't find them.
To get the CRAN dependecies automatically installed, you can use :
install.packages("devtools")
devtools::install_local("MypackageName.zip")

Error while installing package kableExtra in R

I am trying to install kableExtra and get the following errors:
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck =
vI[[j]]) :
there is no package called 'hms'
ERROR: lazy loading failed for package 'kableExtra'
*removing 'C:/Users/Tim/Documents/R/win-library/3.2/kableExtra'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.5/bin/x64/R" CMD INSTALL -l "C:\Users\Tim\Documents\R\win-library\3.2"
C:\Users\Tim\AppData\Local\Temp\RtmpUJQfwD/downloaded_packages/kableExtra_0.9.0.
tar.gz' had status 1
Warning in install.packages :
installation of package ‘kableExtra’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\Tim\AppData\Local\Temp\RtmpUJQfwD\downloaded_packages’
How can I solve my problem? Thanks in advance!
it seems kableExtra depends on the package "hms" so try install it before with:
install.packages("hms")
or via rstudio interface:
packages -> install
and type in "hms"
also try this command:
install.packages("kableExtra", dependencies = TRUE)
If there appear problems like installing rlang or something similar, there is no general solution for this. You can try to (re)install rtools. Sometimes there are missing parts of r installations. My guess if R can't install a dependencie is, that some library or tools of the R environment are missing or wrongly installed which have to be detected.
You have a trouble with the dependency with the package "hms". I have not got how you are installing the r package, but you can either install it first and then try it again or start the installation with the option of download and install all required dependencies, in the second option you need to be online and allow the package manager to intall what is required.
Here is how it looks in RGui. I guess your are not using RGui.

Some Packages not Running on R Version 1.0.153 [duplicate]

I had everything working with R and RStudio, but then I moved the folders when cleaning up my computer directories & files. Now I'm getting the error message below.
Should R and RStudio be installed under Program Files or Program Files (x86)? Should I have two libPaths?
install.packages("C:/Users/kevin/Downloads/fpp_0.5.zip", repos = NULL)
## Warning in install.packages :
## package ‘C:/Users/kevin/Downloads/fpp_0.5.zip’
## is not available (for R version 3.0.0)
## Installing package into ‘C:/Users/kevin/Documents/R/win-library/3.0’
## (as ‘lib’ is unspecified)
## package ‘fpp’ successfully unpacked and MD5 sums checked
library("fpp", lib.loc="C:/Users/kevin/Documents/R/win-library/3.0")
Loading required package: forecast
## Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
## there is no package called ‘colorspace’
## Error: package ‘forecast’ could not be loaded
When you install the package using the RStudio package installer or directly from CRAN, it doesn't install the dependencies ("fracdiff", "Rcpp", "RcppArmadillo" and "colorspace") and hence, R keeps throwing the load namespace error. Installing the package through, automatically installs all the dependencies and solves this problem.
install.packages("forecast",
repos = c("http://rstudio.org/_packages",
"http://cran.rstudio.com"))
The last time I encountered a very similar problem, I used this code which I got somewhere:
install.packages("package's name", repos=c("http://rstudio.org/_packages", "http://cran.rstudio.com"))
simply put your package's name in the quotation marks.
Hope this helps.
Use this:
install.packages("colorspace", dependencies = TRUE)
I ran into this problem. It turned out that my .Rprofile had calls to a package that was not installed. Removing these lines allowed installation to proceed normally.
I got this error while installing the library 'tidyverse'. Removed the error by upgrading R from v3.4 to v3.6

R cran Impossible to install dependencies recursively from install_github from devtools

I try to test my package developed on Ubuntu 16.04 with Windows 7. For both platforms I work on R 3.3.1 (but I also test on 3.3.0).
My package is saved on my GitHub repo (https://github.com/charlottesirot/elementR). When I run this command from Ubuntu, no problem happens:
library(devtools)
install_github("charlottesirot/elementR", dependencies = T , force = T)
but with windows 7, I have the following answer:
Downloading GitHub repo charlottesirot/elementR#master from URL
https://api.github.com/repos/charlottesirot/elementR/zipball/master
Installing elementR "C:/PROGRA~1/R/R-33~1.1/bin/i386/R" --no-site-file
--no-environ --no-save --no-restore --quiet CMD \ INSTALL \ "C:/Users/Cha/AppData/Local/Temp/RtmpUX1GVA/devtoolsa907a336b/charlottesirot-elementR-103e064"
\ --library="C:/Users/Cha/Documents/R/win-library/3.3"
--install-tests
installing source package 'elementR' ...
** R
** inst
** preparing package for lazy loading Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no
package called 'XML' ERROR: lazy loading failed for package 'elementR'
removing 'C:/Users/Cha/Documents/R/win-library/3.3/elementR' Error: Command failed (1)
As I understand, R tries to install the dependencies of my package (e.g. Shiny...) but it does not manage to install the dependencies of the dependencies (e.g. XML from gnumeric package)
Thus I try to manually install XML thinking that perhaps there was a problem with XML and then:
installing source package 'elementR' ...
** R
** inst
** preparing package for lazy loading Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there
is no package called 'gtools' ERROR: lazy loading failed for package
'elementR'
removing 'C:/Users/Cha/Documents/R/win-library/3.3/elementR'
I cannot install all the packages manually, it does not make sense !!!
Moreover when I try something less cryptic than my package, thinking that I could makea mistake in my code:
install_github("hadley/ggplot2", force = T)
installing source package 'ggplot2' ...
** R
** data
*** moving datasets to lazyload DB
** inst
** tests
** preparing package for lazy loading Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no package called 'assertthat' ERROR: lazy loading failed for package 'ggplot2'
removing 'C:/Users/Cha/Documents/R/win-library/3.3/ggplot2'
restoring previous 'C:/Users/Cha/Documents/R/win-library/3.3/ggplot2' Error: Command failed (1
)
I think there is a problem from the install_github ???
What do you think ??
Here is my Namespace:
exportPattern("^[[:alpha:]]+")
importFrom(R6, R6Class)
importFrom(shinyjs, colourInput)
importFrom(shinyjs, delay)
importFrom(shinyjs, useShinyjs)
importFrom(gnumeric, read.gnumeric.sheet)
importFrom(abind, abind)
importFrom(tcltk2, tk2text)
importFrom(gdata, read.xls)
importFrom("readODS", read.ods)
importFrom("grDevices", "bmp", "colorRampPalette", "dev.off", "jpeg",
"png", "rainbow", "tiff")
importFrom("graphics", "abline", "layout", "legend", "mtext", "par",
"plot", "points", "rect", "text", "title")
importFrom("stats", "sd")
importFrom("utils", "read.table", "write.csv", "write.table")
import(shinydashboard, shiny, stringr, lmtest, reader, devtools, tcltk)
For me, it looks ok but what do you think ?
I looked at a lot of article on internet but I only found one message which is exactly the same than my case but it is not enough informative :
Cannot install "flexdashboard package"
I am totally stuck at this point and I would like to have your help regarding this issue.
Thank you verrrrrry much in advance !!
CHa
Recently, I encountered a similar or maybe related issue. As it turned out, there was a bug in devtools install_github, missing the correct installation of dependencies, despite dependecies=TRUE. Have a look at: Does install_github recursively install dependencies? If the problem persists, better contact the authors directly via their github repository.
Plus, I just observed another issue arising after a Windows update, during which permissions seemed to have been altered to download or update packages into personal Win User libraries instead of the "default" R library folder. I suspect devtools seemed consequently lost as to which packages were loaded or available at which versioning. A fresh R reinstallation (i.e., library folder cleansing) solved that issue, but such may not always be convenient.

Resources