Failing to install Kieran Healy's 'socviz' package from github using devtools - r

I am trying to follow along with the online data viz resource by Kieran Healy (socviz.co), and have had minimal trouble setting things up to do so. I cannot seem to successfully install his 'socviz' package. This is the code Healy suggests:
devtools::install_github('kjhealy/socviz')
This returns:
ERROR: dependency 'rlang' is not available for package 'socviz'
* removing 'C:/Users/annem/OneDrive/Documents/R/win-library/3.4/socviz'
Installation failed: Command failed (1)
I tried removing and reinstalling 'rlang', but I still received the same error. I have also tried restarting R.
When reinstalling 'rlang', I get the following:
package ‘rlang’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘rlang’
And when trying to load:
library(rlang)
Error in library(rlang) : there is no package called ‘rlang’
I'm using R v 3.4.2 on Windows 10.
I'm relatively new to R, so if there's a seemingly obvious solution (or you think it could be solved by doing something I've already done) let me know!
It's very possible I'm making a silly mistake, but I haven't found it myself. Any help is appreciated!

Turns out the problem was in how I was removing 'rlang'. I was attempting to using remove.packages() while the package was loaded into my session. I deleted it from my machine directly, but as Tung mentioned, using the remove.packages() command works as long as it is not loaded into the current R session.
Lesson learned--thanks!

Related

How to solve expss package loading problem

I would like to install the expss package but it keeps returning an error.
Looked around for other with similar problems and tried re-installing several packages but nothing seems to work. Does anyone have a suggestion how to fixed the problem?
So far i tried re-installing:
install.packages("stringr")
install.packages("knitr")
install.packages("checkmate")
install.packages("htmlwidgets")
install.packages("htmltools")
install.packages("htmlTable")
install.packages("expss")
But Rstudio keeps returning with and error :
Error: package or namespace load failed for ‘expss’:
object 'mtfrm' not found whilst loading namespace 'expss'
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/expss’
Warning in install.packages :
installation of package ‘expss’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/cl/5_wnd4b14y7b40zc80n1r3wdkcnbkn/T/RtmpdcLWsn/downloaded_packages’
According to this issue, the current version of expss won't install in versions of R before 4.2. This has recently been fixed in the development version. You could try:
updating your version of R to version 4.2 (probably the simplest solution if you don't need to keep an older version of R)
installing the development version of expss from GitHub: first install the remotes package, then remotes::install_github("gdemin/expss")
install an older version of expss (remotes::install_version("expss", "0.11.1"))

Error reading file while installing package devtools (R)

I've recently installed devtools looking to create my first package. At some point I tried loading the library, and got an error when 'devtools' tried to load the dependent library 'usethis'. Whenever I'd try to install it I'd get "error reading from connection". All solutions I could find online involved restarting R and my computer. Neither worked.
Finally, I manually deleted the folder, downloaded the .zip file from CRAN, and manually installed 'usethis'. I can now load 'usethis'.
I then tried loading 'devtools' but got the same error, but now for devtools.
> install.packages(pkgs = "C:/Users/.../Downloads/devtools_2.4.3.zip",repos = NULL)
Installing package into ‘C:/Users/.../OneDrive/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
package ‘devtools’ successfully unpacked and MD5 sums checked
> library(devtools)
Loading required package: usethis
Error: package or namespace load failed for ‘devtools’ in readRDS(nsInfoFilePath):
error reading from connection
In addition: Warning messages:
1: package ‘devtools’ was built under R version 4.1.3
2: package ‘usethis’ was built under R version 4.2.0
3: In readRDS(nsInfoFilePath) : error reading the file
I tried reinstalling the package, both from CRAN and manually. I restarted R and restarted my computer, all multiple times. I even reinstalled 'usethis'.
When I reinstall devtools manually the installation exists without an error. But when I actually load it, I get the error above.
My computer is a standard personal Windows PC. No fancy configurations or firewall (beyond the standard - though that shouldn't be an issue when manually installing anyway I think). I've used this same set up for months, and have installed and used dozens of packages.
Any help would be highly appreciated.

Error in rbind(info, getNamespaceInfo(env, "S3methods")) when installing factoextra

I'm trying to install the "factoextra" package using a local source tar ball on Windows. I can install other packages in the same way with no problem. However, when installing "factoextra", I get an error relating to S3methods.
I have tried using local windows binaries, installing the latest Rtools and made sure I have all the dependencies installed. I have also tried to use archived versions of the package.
install.packages('D:\\R_Packages\\Packages\\factoextra_1.0.5.tar.gz', repos = NULL, type="source")
* installing *source* package 'factoextra' ...
** package 'factoextra' successfully unpacked and MD5 sums checked
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
Error in rbind(info, getNamespaceInfo(env, "S3methods")) :
number of columns of matrices must match (see arg 2)
ERROR: lazy loading failed for package 'factoextra'
* removing 'D:/R-3.5.2/library/factoextra'
In R CMD INSTALL
Warning in install.packages :
installation of package ‘D:/R_Packages/Packages/factoextra_1.0.5.tar.gz’ had non-zero exit status
I really just need this package to install.
I found this thread: http://r.789695.n4.nabble.com/Error-in-rbind-info-getNamespaceInfo-env-quot-S3methods-quot-td4755490.html, which leads me to how I solved a similar issue on my machine.
I found that a broken version of the package was installed on my system and had to be removed manually before I could install a clean version.
Find if and where factoextra is installed (it might be on your system, just outdated or broken):
find.package("factoextra")
If it's there already (just broken), you can try to remove it with:
remove.packages("factoextra")
If remove.packages() fails even though find.packages() says the package is there, use the path returned by find.packages() to use your OS' file system to find and delete the package - just be careful only to delete stuff you know is broken.
Once the old, broken package is removed, use install.packages("factoextra") and it should work.
I had several packages that were broken in this way. If that's the case for you, you can identify which packages to remove and install this way by using something like:
allPackages <- installed.packages()[, 1]
findBrokenPackages <- function(packages) {
for (p in packages) {
tryCatch(ncol(asNamespace(p)$.__NAMESPACE__.$S3methods),
error = function(e) print(c(p, e)))
}
}
findBrokenPackages(allPackages)
This will print out any packages that have the same issue. I would suggest removing all broken packages before trying to use install.packages() again.

Unable to install new R packages in DSX Desktop

I've just installed DSX Desktop with RStudio. I'm unable to load new packages, e.g. lubridate, and get the error below. If I check for package updates, I get the message "all packages are up-to-date", but the error below suggests it needs a newer version of Rcpp.
installing to /user-home/_global_/R/lubridate/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace ‘Rcpp’ 0.12.9.2 is already loaded, but >= 0.12.13 is required
ERROR: lazy loading failed for package ‘lubridate’
* removing ‘/user-home/_global_/R/lubridate’
Warning in install.packages :
installation of package ‘lubridate’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpIV4HWl/downloaded_packages’
I tried install.packages("Rcpp") which returned the message:
Error in unloadNamespace(pkg_name) :
namespace ‘Rcpp’ is imported by ‘httpuv’, ‘reshape2’, ‘tidyr’, ‘bindrcpp’, ‘tibble’, ‘htmltools’, ‘dplyr’, ‘plyr’ so cannot be unloaded
If I try remove.packages("Rcpp") or removing the packages above, I get the following message, and they remain in the Packages view.
Removing package from ‘/user-home/_global_/R’
(as ‘lib’ is unspecified)
Error in remove.packages : there is no package called ‘Rcpp’
Any advice please on how to proceed?
There seems to be a fundamental problem with RStudio. I encountered exactly the same problems you describe with the latest version (1.1.442). The problems are:
Packages viewed as out-of-date go into a loop when installing with a repeated error dialog box appearing.
The package version check refers out-of-date packages and will not install the current package versions showing on CRAN. This is due to RStudio pointing at a MRAN mirror that has old updates. This means that all packages stored there are out of date. You can see when the packages on MRAN were last updated here.
Removal of other packages (e.g. dependencies) doesn't work properly, and manual deletion of the folders doesn't solve the problem.
Inside Tools, Global options, Packages there is the ability to specify the mirror that should be used for package management. This doesn't seem to work.
I fixed my problem by going into R and performing a package update inside that. RStudio now uses the updated packages.
I have contacted RStudio about this and received the reply that they don't provide support for free versions of RStudio.
tl;dr: RStudio appears to be broken for updating packages. Use R itself for updates.
I was getting this error:
Windows 7, update.packages problem: “unable to move temporary installation”? Which I think was due to my antivirus, but not sure. MRAN version was 3.3.1 and this is what I would do to fix this error everytime I opened R-Studio and needed to install:
trace(utils:::unpackPkgZip, edit=TRUE)
# Edit line 142 - change Sys.sleep(2.5)
I was still having versioning issues with tidyverse, so looked around and decided to install the latest MRAN from Microsoft and that fixed all of my R-Studio versioning issues and install inssues. I had other issues where I was doing a work.
Version info:
Microsoft R Open 3.5.1
The enhanced R distribution from Microsoft
Default CRAN mirror snapshot taken on 2018-08-01.
Download Microsoft R Open 3.5.1

Causes of "Error: package '_____' was built before 3.0.0: please re-install it" in R

On one computer running R 2.15.2 I have installed packages from a .zip file (these packages happened to be ggplot2 and data.table, but I don't think the specific package is my issue.) Everything works fine. I took these packages to a computer without an internet connection and installed them. This other computer is running R 3.0.1. The packages seemed to install without a problem (using R's "install package(s) from local zip file" option). When I call the packages with the library(), I get the following error:
Error: package '<insert name of newly installed package here>' was build before 3.0.0: please-re-install it
Can anyone explain potential causes for this error to be thrown? Are there particular directories that the .zip packages must be in for a proper install? If R is installed on a separate partition from where the .zip packages were loaded, could this cause the error?
I'm at a loss, any pointers are greatly appreciated. This is a difficult one to reproduce; if you need any other version/system parameters to understand the problem, please don't hesitate to ask.
I found this solution while look at GitHub ggplot2 issue #796
update.packages(checkBuilt = TRUE, ask = FALSE)
It will update all the packages that need to be reinstalled.
Running install.packages("codetools") can fix this issue for R 3.0.2, if you have the same problem like me:
installing to /home/user/R/x86_64-pc-linux-gnu-library/3.0/Rcpp/libs
** R
** inst
** preparing package for lazy loading
Error : package ‘**codetools**’ was built before R 3.0.0: please re-install it
Error : unable to load R code in package ‘Rcpp’
ERROR: lazy loading failed for package ‘Rcpp’
I installed shiny according https://github.com/rstudio/shiny-server/wiki/Ubuntu-step-by-step-install-instructions
and got the same error at the step
sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""
Warning messages:
1: In install.packages("shiny", repos = "http://cran.rstudio.com/") :
installation of package ‘Rcpp’ had non-zero exit status
2: In install.packages("shiny", repos = "http://cran.rstudio.com/") :
installation of package ‘httpuv’ had non-zero exit status
3: In install.packages("shiny", repos = "http://cran.rstudio.com/") :
installation of package ‘shiny’ had non-zero exit status
I tried the answer by Richard Lee by starting R
R
and got the error
Warning in install.packages("shiny") :
'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead? (y/n) n
Error in install.packages("shiny") : unable to install packages
obviously no write permission, so
sudo R
Now I tried again
install.packages("shiny")
and got a number of errors
Error : package ‘codetools’ was built before R 3.0.0: please re-install it
Error : package ‘RJSONIO’ was built before R 3.0.0: please re-install it
Error : package ‘caTools’ was built before R 3.0.0: please re-install it
Error : package ‘bitops’ was built before R 3.0.0: please re-install it
Error : package ‘digest’ was built before R 3.0.0: please re-install it
Error : package ‘xtable’ was built before R 3.0.0: please re-install it
Each time I got an error, I re-installed the requested package
install.packages("codetools")
install.packages("RJSONIO")
etc.
and eventually, I was able to install Rccp, httpuv, and even shiny.
Now it works!!
Also see
Shiny package installation on R version 3.0.2 "Frisbee Sailing"
I am using rkward on precise
I had a similar error using rkward. Specifically this one:
'lib = "/usr/local/lib/R/site-library"' is not writable
I temporarily changed the permissions for this directory so that rkward could run this from its console:
update.packages(checkBuilt = TRUE, ask = FALSE)
all to fix this:
Error: package '' was build before 3.0.0: please-re-install it
so that (sigh...) I could fix 'default' configuration for audio on precise. I couldn't use play() etc. in rkward.
That just needed phonon-backend-gtstreamer
I tried to install swirl on R(v3.1.0) on ubuntu 12.04LTS:
sudo R
install.packages("swirl")
But faced a similar error:
Error : package ‘codetools’ was built before R 3.0.0: please re-install it
Error : unable to load R code in package ‘httr’
ERROR: lazy loading failed for package ‘httr’
* removing ‘/usr/local/lib/R/site-library/httr’
ERROR: dependencies ‘testthat’, ‘httr’ are not available for package ‘swirl’
* removing ‘/usr/local/lib/R/site-library/swirl’
Doing following helped me:
install.packages('codetools')
install.packages("swirl")
library("swirl")
swirl()
| Welcome to swirl! Please sign in. If you've been here before, use the same
| name as you did then. If you are new, call yourself something unique.
What shall I call you?
I hope the same may help fix your installation issue.
Here is the work-around that I used:
I installed the latest version of R on an internet-capable computer. I then loaded the my required packages (Packages->install packages->select mirror->select package...
After R is finished installing, it displays a message of where the temporary .zip package is located. I navigated to this location, grabbed the temp package, and burnt it to a cd.
In this way, I could get the newer package build onto a computer without internet access. I would still be interested to know if there is an easy way to rebuild a package downloaded on an early R version to make it compatible with the latest version (without needed an internet connection).
Thanks for pointing me in the right direction #JoshuaUlrich

Resources