Using any Library to Read Excel files from R - r

I have R installed in a usb stick (since I'm using work computer and don't have Admin access to install software), and so far I've been having to resort to read.csv() since I can't use any library to read excel files.
For example, XLConnect gives the problem of :
>Error: package or namespace load failed for ‘XLConnect’:
>> .onLoad failed in loadNamespace() for 'rJava', details:<br>
>> call: inDL(x, as.logical(local), as.logical(now), ...)<br>
>> error: unable to load shared object 'D:/R/R-4.0.2/library/rJava/libs/x64/rJava.dll':<br>
> LoadLibrary failure: %1 is not a valid Win32 application.<br>
>In addition: Warning message:
>package ‘XLConnect’ was built under R version 4.0.3
It seems that these libraries (readxl, xlsx, or XLConnect) are failing because they don't know where I have Java installed. So, I also did this:
Sys.setenv(JAVA_HOME='C:\Program Files (x86)\Java\jre1.8.0_131\bin')
but, to no avail. (that advice I got it from https://www.r-statistics.com/2012/08/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/)
If someone knows how to read excel files using R from a memory stick - I would really appreciate if they can point north to me.
btw, this is the error when loading xlsx library:
> library(xlsx)
>Error: package or namespace load failed for ‘xlsx’:
>> .onLoad failed in loadNamespace() for 'rJava', details:<br>
>> call: inDL(x, as.logical(local), as.logical(now), ...)<br>
>> error: unable to load shared object 'D:/R/R-4.0.2/library/rJava/libs/x64/rJava.dll':<br>
>> LoadLibrary failure: %1 is not a valid Win32 application.
<br>
>In addition: Warning message:<br>
>package ‘xlsx’ was built under R version 4.0.3
and this is the error when trying to read an excel file with readxl (no problem when loading):
>*Error in loadNamespace(name) : there is no package called ‘cli’*

This is it, this did it:
"You may want to check out this posting: stackoverflow.com/questions/29254067/…" – SteveM 16 hours
Thank you kind stranger.

Related

stats package not found in R

I'm really having problems with RStudio.
It had been working fine a few days ago. Then it said I needed the newest version of RTools. I tried to install it but don't think it was successful. However now I can't load anything in R.
I am greeted with the following message when launching RStudio:
Error: package or namespace load failed for ‘stats’ in inDL(x, as.logical(local), as.logical(now), ...):
unable to load shared object 'C:/Program Files/R/R-3.6.3/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.
During startup - Warning message:
package ‘stats’ in options("defaultPackages") was not found
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Program Files/R/R-3.6.3/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.
I have looked up solutions to this problem and people say to delete /Renviron but I don't know will that mess things up even more.
Here are a few results of things I type into R:
> Sys.getenv("PATH")
[1] "C:\rtools40"
> Sys.which("stats.dll")
stats.dll
""
> Sys.which("make")
make
""
I really don't understand what has gone wrong. Can anyone help?
You accidentally overwrote the PATH envvar. Your line in .Renviron must be: PATH="C:/rtools40/usr/bin;${PATH}" (mind the " and the {}), otherwise you'll lose the R installation path and R will not be able to load the shared library.

Package ("qdap") fails to load with multiple errors

While installing qdap I have not faced any errors. But when loading the library, I face the follwing errors.
> library(qdap)
Loading required package: qdapDictionaries
Loading required package: qdapRegex
Loading required package: qdapTools
Loading required package: RColorBrewer
Error: package or namespace load failed for ‘qdap’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
I read in another question that we need to install the JAVA 64bit (as my Win 10 is 64-bit) and load the JAVA home. So I downloaded the 64-bit java file and also set the JAVA_HOME to the directory.
> Sys.setenv(JAVA_HOME='C:/Program Files (x86)/Java/jre1.8.0_231')
> library(qdap)
Error: package or namespace load failed for ‘qdap’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/Admin/Documents/R/win-library/3.6/rJava/libs/x64/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
I have uninstalled and installed the latest R software (3.6.2; I've checked both 32-bit and 64-bit options), restarted R-studio as well, to no avail.
The issue is fixed. Although I'm not 100% sure what solved, here is what i have done.
The error %1 is not a valid Win32 application. is indicating 32-bit.
So I started Rgui console (32-bit) (opened from the directory C:\Program Files\R\R-3.6.2\bin\i386 ). The library(rJava) command works well and so does library(qdap).
Then I changed the options in Rstudio to choose 32-bit R [Tools -> Options -> General]. But setting this will impact high memory consuming executions. After a while (when I started facing memory issues), I switched the RStudio to use the 64-bit R.
The error did not appear after that and I was able to load the 'qdap' library.

Error in opening R packages

I have installed some packages on R Studio on my laptop, and I am having some issues opening them. When I try
require(ggplot)
I get this error:
Error: package or namespace load failed for ‘ggplot2’ in inDL(x, as.logical(local), as.logical(now), ...):
unable to load shared object 'C:/Users/marky/OneDrive/Documents/R/win-library/3.4/Rcpp/libs/x64/Rcpp.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
Any clue to what is going on? It appears that Rcpp has something to do with converting C++ to R. When I go to the directory, I see it (although the size is 0KB). I also get this error on the UI

Rmpi.dll "could not be found" with DeinoMPI and Rmpi

I'm trying to set up MPI with DeinoMPI on Windows. I've installed DeinoMPI and have my cluster set up there, but when I run library(Rmpi) after starting Rgui.exe through the cluster I get the following error:
> library(Rmpi)
Error : .onLoad failed in loadNamespace() for 'Rmpi', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'D:/Programs/R-3.1.0/library/Rmpi/libs/x64/Rmpi.dll':
LoadLibrary failure: The specified module could not be found.
In addition: Warning message:
package ‘Rmpi’ was built under R version 3.1.1
Error: package or namespace load failed for ‘Rmpi’
Looking at that directory, Rmpi.dll is present in the directory and has read/write access. Anyone have any ideas why it says 'the specified module could not be found'? Or is there some additional config necessary perhaps?
Additionally, if I run Rgui.exe outside of the DeinoMPI cluster and run library(Rmpi), I receive the following pop-up:

Error loading rJava in R (Ubuntu 12.04)

I had some issues installing rJava first. Then I found this solution.
Unfortunately I get following error, when loading the package:
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/informatik2/students/home/1jendryc/R/x86_64-pc-linux-gnu-library/3.1/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or directory
Error: package or namespace load failed for ‘rJava’
Still this file exists and even the path is correct
~/R/x86_64-pc-linux-gnu-library/3.1/rJava/libs$ ls
rJava.so
So I tried that approach, but it didn't worked.
I have no possibility to get root easily, cause I am working at my university at a pool computer.
Cheers.
Your issue is something different. What message says is that it can't find "libjvm.so". You need to properly configure Java, rJava and R. Take a look here
http://www.owsiak.org/?p=3671
where all the caveats are listed when it comes to working with R and Java.

Resources