Trouble Installing rlang and TidyVerse - r

I am using RGui 3.5.1 and RStudio 1.2.5. I am trying to load Tidyverse and it gave some error message about "onload failed in loadNameSpace() for 'rlang' " so I think maybe I need to load rlang first, but I got the same error message.
I have been going around the circle for days now, tried everything suggested online, except to uninstall the R studio as we need to go through IT for it (R is in local software center which we are able to download ourselves so I did uninstall R and install it myself but its still not working).
Following advice found online,
I deleted rlang then checked on R:
library("rlang")
Error in library("rlang") : there is no package called ‘rlang’
Then I made sure the CRANExtra is removed
setRepositories()
Then I specified the library location to install
install.packages("rlang",lib="C:/Users/LIN0001/DataNow/Home/R/win-library/3.5")
trying URL 'https://mran.microsoft.com/snapshot/2018-08-01/bin/windows/contrib/3.5/rlang_0.2.1.zip'
Content type 'application/zip' length 821580 bytes (802 KB)
downloaded 802 KB
package ‘rlang’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\LIN0001\AppData\Local\Temp\RtmpigNMZO\downloaded_packages
---Then I try to load it from the same folder:
library("rlang",lib.loc="C:/Users/LIN0001/DataNow/Home/R/win-library/3.5")
Error: package or namespace load failed for ‘rlang’:
.onLoad failed in loadNamespace() for 'rlang', details:
call: dots_list(...)
error: object 'rlang_dots_list' not found
I also unticked the "use secure download method for http" of packages option in RStudio and when installing Tidyverse, I selected No instead of Yes on the pop up window (can't remember the exact message, something to do with security again); I have tried to load it both on R and Rstudio but got the same error messages.
Now I ran out of options to try so please help.
Many thanks in advance.

Related

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.

SOLVED: Why am I having the errors below with updating package: rlang when I have closed everything out and even removed the old package?

SOLVED: See solution in answers below
I was trying to install a package and it said I need the latest version of 'rlang'
So i went to update it and I get the message
Warning in install.packages :
cannot remove prior installation of package ‘rlang’
Warning in install.packages :
restored ‘rlang’
So I tried restarting R and closing all projects etc., I tried restarting my computer....no go
Next I tried remove.packeges(rlang)
It said it can't remove it, but now I can't find rlang in my packeges.
I tried to install rlang and I get the same message as above as if I still have it installed
I run library(rlang) and get the following messages:
Error in library("rlang") : there is no package called ‘rlang’
So now i don't have rlang? but my computer can't remove the latest version...which isn't there? I have restarted the program quite a few times and have everything closed that could have rlang open.
install.packages("rlang")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/rlang_0.4.7.zip'
Content type 'application/zip' length 1149015 bytes (1.1 MB)
downloaded 1.1 MB
package ‘rlang’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘rlang’
Warning in install.packages :
restored ‘rlang’
The downloaded binary packages are in
[enter image description here][1]
please see picture below showing I do not have rlang installed
[1]: https://i.stack.imgur.com/CliaA.png
Use whatever search tools you use to find any possible instance of "rlang." Your problem sounds like it got installed locally rather than globally, or vice versa, and that's why remove.packages may not see it.
The idea is to check whether there's more than one location where R/libraries directories might exist, and purge rlang from all of them.

R package updates

I have been having some issues accessing an updated version of a package in R.
On running a workflow for data analysis I got this error message:
library(dplyr)
Error: package or namespace load failed for ‘dplyr’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
namespace ‘rlang’ 0.2.1 is already loaded, but >= 0.2.2 is required
I therefore tried to update both the "dplyr" and "rlang" packages.
On updating I get the messages:
Installing package into ‘C:/Users/tomsp/OneDrive/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://cran.ma.imperial.ac.uk/bin/windows/contrib/3.5/rlang_0.2.2.zip'
Content type 'application/zip' length 820944 bytes (801 KB)
downloaded 801 KB
package ‘rlang’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘rlang’
The downloaded binary packages are in
C:\Users\tomsp\AppData\Local\Temp\RtmpmooXKa\downloaded_packages
However if I check the package using the code below it still has version 0.2.1
packageVersion("rlang")
[1] ‘0.2.1’
I checked my library paths and still have not managed to be run the latest version(0.2.2) of the package rlang.
Any advice of what I am doing wrong or how I can solve this?
Restart R and run install.packages again. On Windows, you can't update a package that's already loaded, if the package contains compiled C/C++/Fortran code. This includes dplyr and rlang.
To be doubly sure, before you run install.packages, go to your R packages directory (C:/Users/tomsp/OneDrive/Documents/R/win-library/3.5) and delete any zero-length files that are present. These are artifacts of failed install attempts and will break install.packages if present.
For any reason, at least in Windows, some R processes may still be running in background. Close your current R session, kill all processes related to R and try again.
If you are using Windows, check if the package you are trying to upgrade is available only as a source file.
If you try to install a package that needs compilation, you need the software Rtools. Download it on cran.r-project.org/bin/windows/Rtools/. Updating Rtools might also resolve your problem. The console message for a particular package is like that:
binary source needs_compilation
backports 1.2.0 1.2.1 TRUE
On Linux you don't need Rtools, but read the console output when you see an error when you try to install or update a package. If some software is missing, the error message on Linux is self-explanatory.
Deleted the entire library from R packages directory on my local computer. Installed again after terminating the session. Worked for me.

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

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!

R libraries and paths - overview

I am using R Studio with R version 3.1.
I am a bit confused about how the overall file paths and conventions work.
If someone has a link to a good explanation that would be great.
I want to know if a package needs to be installed into the working directory ie do i need to set lib = "/xx/yy/zz" to the same place as the getwd() returns ?
I have supposedly succesfully installed RWeka --- package ‘RWeka’ successfully unpacked and MD5 sums checked
however when I try "library("RWeka") i get the
"Error in library("Rweka") : there is no package called ‘Rweka’ "
After I had installed the package it said
"package ‘RWeka’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
Installing package into ‘C:/Users/MY NAME/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
hence the question - are all packages downloaded to the place where R is installed and thats ok as long as all the code and files we are trying to access are in the set working director.
Many thanks
Here is the train
RWeka installed successfully
however library(RWeka) shows the following
install.packages("RWeka")
Installing package into ‘C:/Users/My Name/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/RWeka_0.4-23.zip'
Content type 'application/zip' length 535623 bytes (523 Kb)
opened URL
downloaded 523 Kb
package ‘RWeka’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\My Name\AppData\Local\Temp\RtmpOc8SpX\downloaded_packages
library(RWeka)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
Error: package or namespace load failed for ‘RWeka’
So I guess the questions are
1. Something else to do other than installing Java from Java.com (have uninstalled and reinstalled no change)
2. I am using R 3.1.1
Please check if you are running R or R Studio on 32 or 64 bit version. Java and R must both be running the same version of architecture.
Andy / Prakash are correct - the function in R
Sys.getenv("R_ARCH") will tell you whether you are running the 32 bit or 64 bit version of R
64 bit java can be downloaded here.
https://www.java.com/en/download/faq/java_win64bit.xml#Java%20for%2064-bit

Resources