Changed R 4.0.0 text encoding behaviour? - r

I installed R 4.0.0 and now I am unable to open packages with the library function, however installing packages work just fine. See example with ggplot2:
install.packages("ggplot2")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/axehe47/OneDrive - Linköpings universitet/Dokument/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/ggplot2_3.3.0.zip'
Content type 'application/zip' length 4015190 bytes (3.8 MB)
downloaded 3.8 MB
package ‘ggplot2’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\axehe47\AppData\Local\Temp\RtmpgbP5K2\downloaded_packages
As you can see it installed the package properly into the directory but when I try to open the package with library I get this result:
library(ggplot2)
Error: package or namespace load failed for ‘ggplot2’ in get(Info[i, 1], envir = env):
cannot open file 'C:/Users/axehe47/OneDrive - Linköpings universitet/Dokument/R/win-library/4.0/rlang/R/rlang.rdb': No such file or directory
Here the "ö" has changed to "ö" which caused a "No such file or directory" error. It seems weird to me since install.packages doesn't show the same behaviour as library.
Furthermore, in Rmarkdown "å", "ä" and "ö" has changed characters which to me seems like they changed the text encoder (or what you call it), thus I wonder if I somehow can change how R encode text characters? Or is there something I can do to change this in any R settings?
It worked R 3.6.1 so I skimmed through the update news but didn't find anything relevant, but I could easily have missed something.
(ps. I ususally use Rstudio and have the default text encoding for saving set to ISO8859-1, this is not the issue. Also, I get the same behaviour for R and Rstudio)

Related

Problem with installing Rtools: cannot locate the file in PATH

I'm trying to download the package "Seurat" in R, the package is installed and it's now in my list of packages.
** testing if installed package keeps a record of temporary installation path
* DONE (patchwork)
The downloaded source packages are in
‘C:\Users\parnian\AppData\Local\Temp\RtmpAVgSd8\downloaded_packages’
But when I try to call it (library(Seurat)) I get the following error:
> library(Seurat)
Error: package or namespace load failed for ‘Seurat’:
object ‘wrap_plots’ is not exported by 'namespace:patchwork'
I read the similar questions and manually installed "patchwork":
> install.packages("patchwork")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/parnian/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
R also tells me to install Rtools whhich I have, but when I follow these commands:
> writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")
but when I want to verify that make can be found (Sys.which("make")), I get this:
> Sys.which("make")
make
""
Also the downloaded packages of Seurat are saved in a location that doesn't even exist in my computer! How is that possible?
How can I fix this? Is there something wrong with the address I write for the path?
Thank you

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.

Persistent problems installing the car package in R

I'm having problems installing the package car in R.
There are previous posts on the topic, including this one and this other one.
I have followed the suggestions I've come across so far without success. I am using R Version 3.2.2. and RStudio.
This is the message I get:
install.packages("car")
Installing package into ‘C:/Users/.../Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/car_2.1-3.zip'
Content type 'application/zip' length 1447213 bytes (1.4 MB)
downloaded 1.4 MB
package ‘car’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\...\AppData\Local\Temp\Rtmpc3xr5i\downloaded_packages
If I check I get,
?car
No documentation for ‘car’ in specified packages and libraries:
you could try ‘??car’
I tried installing it from R with Install packages from local zip drives, and looking for the zip in C:\Users\...\AppData\Local\Temp\Rtmpc3xr5i\downloaded_packages, but this is the result:
library(car)
Error in library.dynam(lib, package, package.lib) :
DLL ‘SparseM’ not found: maybe not installed for this architecture?
In addition: Warning message:
package ‘car’ was built under R version 3.2.5
Error: package or namespace load failed for ‘car’
I did try installing SparseM even before posting the OP without success:
> install.packages("SparseM")
Installing package into ‘C:/Users/.../Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/SparseM_1.7.zip'
Content type 'application/zip' length 795531 bytes (776 KB)
downloaded 776 KB
package ‘SparseM’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\...\AppData\Local\Temp\Rtmpc3xr5i\downloaded_packages
> ?SparseM
No documentation for ‘SparseM’ in specified packages and libraries:
you could try ‘??SparseM’
Follow up:
After a comment regarding R version 3.2.3 I thought it would be an easy fix to just download this version, install, and erase 3.2.2. The problem then is that RStudio did not seem to work. I un-installed and re-installed R-studio, and now I get this when opening R studio:
Without knowing what version of the car package you're using, it's hard to know exactly what the source of the problem is. It seems likely, however, that you haven't installed the proper version of the pbkrtest, on which the Rcmdr package depends.
Is there a compelling reason not to upgrade everything to their current versions, including R, all packages, and RStudio?
Best,
John

R namespaces: how to get imports packages when installing and loading R packages from fresh R install.

I have set up a fresh R and RStudio on a new Win7 x64. When I want to install and load packages (from within RStudio) errors seems to pop up that seems to be related to the packages namespace imports directive. For instance scales when trying to load ggplot2 (with some danish in between):
> install.packages('ggplot2')
Installing package into ‘C:/Users/me/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/ggplot2_1.0.1.zip'
Content type 'application/zip' length 2675576 bytes (2.6 MB)
opened URL
downloaded 2.6 MB
package ‘ggplot2’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\me\AppData\Local\Temp\RtmpodrNFq\downloaded_packages
> library(ggplot2)
Error in get(Info[i, 1], envir = env) :
cannot open file 'C:/Users/me/Documents/R/win-library/3.1/scales/R/scales.rdb': No such file or directory
Error: indlæsning af pakke eller navnerum fejlede for ‘ggplot2’
Would I need to do ´install.packages()´ for package scales (and all other missing packages) or is there a way to have this done more automated when you have a fresh R install.
Surely, I do not grasp the concept of namespaces of the packages and have tried to read other SO questions likethis and this - and ultimately run the risk of a dublicated question.
If you look at the DESCRIPTION file you see:
Depends: R (>= 2.14), stats, methods
Imports: plyr (>= 1.7.1), digest, grid, gtable (>= 0.1.1), reshape2,
scales (>= 0.2.3), proto, MASS
So you are probably seeing a side-effect of not having installed the scales package. You can either look at the DESCRIPTION file using your file browser or by executing:
help(pac=ggplot2) # and click on the DESCRIPTION file link at the top of that page.

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