package ‘rJava’ is in use and will not be installed - r

I have been using R for a while without problems. Just a sudden, i have several issues with Rjava errors. I searched online for clues, but found none.
The error is: Warning in install.packages :
package ‘rJava’ is in use and will not be installed
and now every time i run install.packages, i get a pop box that says uploading loaded packages.....
sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] miniUI_0.1.1.1 tabulizer_0.2.2 rJava_0.9-10
Every time i start RStudio, i get this error:
Loading required package: rJava
Error: package or namespace load failed for ‘rJava’ in exists(what, mode = "function", envir = ns):
reached elapsed time limit
I made sure that i had java versions for 64 bit and the environment was set correctly.
install.packages("rJava");library(rJava)
I want to have a solution so that rjava loads correctly when i start RStudio or install rjava

This looks like you are loading tabulizer on startup, which also loads rJava. I suspect the reason is that you have a file called .RDATA saved in your default working environment. That makes RStudio open and load it on starting. In that file, I suspect there is an object which needs tabulizer. This is why it is loaded on default and why you have these problems.
The solution is to delete or rename the .RDATA file. Use getwd() to find out your current working directory. You might need to make hidden files visible.

Related

Package 'xxx’ was installed before R 4.0.0: please re-install it (already done fresh install and checked lib paths)

I am having some issue with installing a package in R 4.0.2 from binaries. Here is my attempt:
> install.packages("C:/Users/MNestor/Downloads/libSBML_5.18.0.zip", repos = NULL, type = "win.binary")
Installing package into ‘C:/Users/MNestor/Documents/R/win-library/4.0’ (as ‘lib’ is unspecified)
package ‘libSBML’ successfully unpacked and MD5 sums checked
Warning messages:
1: multiple methods tables found for ‘type’
2: multiple methods tables found for ‘type<-’
Next I load library:
> library('libSBML')
Error: package or namespace load failed for ‘libSBML’:
package ‘libSBML’ was installed before R 4.0.0: please re-install it
This error is confusing to me because I am working in R 4.0.2 and have clearly just done a fresh install.
I have tried
deleting the library folder and reinstalling
running remove.packages('libSBML') and reinstalling
For reference here are my library directories:
> .libPaths()
[1] "C:/Users/MNestor/Documents/R/win-library/4.0"
[2] "C:/Program Files/R/R-4.0.2/library"
The libSMBL folder is located in the first library path, and not the second (as expected).
Here is session info:
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] rsbml_2.46.0 BiocGenerics_0.34.0
loaded via a namespace (and not attached):
[1] BiocManager_1.30.10 compiler_4.0.2 tools_4.0.2 remotes_2.2.0
[5] stats4_4.0.2 SBMLR_1.84.0 graph_1.66.0
The error message is maybe a bit confusing, but it's saying the package is already compiled for an earlier version of R. (That's what the option "win.binary" means).
R 4.0 and earlier binaries are not compatible because of updated compilers and build tools.
You'll need to install the package from source, which likely means installing R tools (https://cran.r-project.org/bin/windows/Rtools/) or you'll need to use a version that is pre-built for R 4.0 or later.

Package-specific utils::news() not working in RStudio

I'm trying to bring up news for a package while in RStudio. While the default utils::news() works for generating the base R changelog in the built-in viewer, I can't get it to work for a specific package; it throws an error. The function works fine for specific packages in RGui.
Fresh R session in RStudio 1.2.1335:
news() # this works
news(package = "ggplot2") # this doesn't
Error that I get in viewer: Error in UseMethod("toHTML") : no applicable method for 'toHTML' applied to an object of class "NULL"
Fresh R session in RGui:
news()
news(package = "ggplot2") # both work perfectly
Session info:
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.0 tools_3.6.0 Rcpp_1.0.1 xml2_1.2.0 commonmark_1.7
How can I get the function to output without error in RStudio? If this is not possible, how can I run the function in RStudio but tell it to view the HTML outside of the viewer, e.g., in the browser like RGui?
This looks like an RStudio bug, so probably the best action is to report it to them. As a workaround, you can avoid using their built-in browser by changing the setting for options("browser").
For example, on a Mac outside of RStudio I see
options("browser")
# $browser
# [1] "/usr/bin/open"
and in RStudio running
options(browser = "/usr/bin/open")
disables the built-in browser. I don't know what it defaults to in RGui on Windows, but setting it to the same in RStudio as it is in RGui should get it to work.
Unfortunately, this disables it for everything, not just for news(), so you probably want something like this instead:
save <- options(browser = "/usr/bin/open")
news(package = "ggplot2")
options(save)

Unable to install Github packages in R

I need a packages witch is located on Github. And I am aware that there are multiple solutions to install the package in R.
I am trying to install the package on a Windows server. This is what I tried:
Solution 1 (which is based on the Vignette)
install.packages("devtools")
library("devtools")
devtools::install_github("bmschmidt/wordVectors")
Error: Could not find tools necessary to compile a package
In addition: Warning messages:
1: In strptime(xx, f, tz = tz): unable to identify current timezone 'C':
Please set environment variable 'TZ'
I tried many things to solve this:
Reinstalling Devtools, use the CRAN devtools version
Reinstalling R and Rstudio (installing the latest versions as admin) (Error : Could not find build tools necessary to build)
But still the same error...
So I tried a workaround to install the packages on my computer:
Solution two
Download ZIP file from (https://github.com/bmschmidt/wordVectors)
Unzip the ZIP file
But the result is an error again:
library(devtools)
install("path/to/unzipped/file")
library("wordVectors")
Error there is no packages called wordVectors.
Anyone an idea what is going on? I struggled the whole day with this issue. Help is really appreciated! Thanks!
Edit
Also Rtools is (re)installed (the latest version...)
Edit 2
As requested in the comments (#DJV):
> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server >= 2012 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets
[6] methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.2 tools_3.5.2

Warning whenever I run sourceCpp

I am having trouble running Rcpp on my PC in RStudio. Whenever I sourceCpp() a cpp file, even the Hello World file that comes with Rcpp::Rcpp.package.skeleton(), I get the warning
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]=".../anRpackage/src/../inst/include": The system cannot find the path specified
I searched Stackoverflow and it looks like some people get this warning if they don't have Depends: Rcpp in the DESCRIPTION of their package, but I am just running sourceCpp() so the DESCRIPTION file shouldn't matter (I also changed my DESCRIPTION file).
It is just a warning so the class and functions I wrote do appear in R, but RStudio frequently crashes after I use the functions in R a few times, which may or may not be related.
My session info:
R version 3.1.3 (2015-03-09)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Rcpp_0.12.1 RevoUtilsMath_7.4.1 RevoUtils_7.4.1 RevoMods_7.4.1 RevoScaleR_7.4.1 lattice_0.20-30 rpart_4.1-9
loaded via a namespace (and not attached):
[1] codetools_0.2-10 foreach_1.4.2 grid_3.1.3 iterators_1.0.7 tools_3.1.3
I suppose it is possible that Revolution R is the culprit here, but I have no way of knowing. I would appreciate help, because I don't want to ignore this warning, and it's obviously not ideal for RStudio to crash repeatedly.
Kind Regards
This is still relevant today, so here's my discoveries.
Rcpp can generate interfaces to and from C++ and R.
These are generated with the help of attributes specified in source-files.
From these attributes, the call to Rcpp::compileAttributes() produces the headers. Whilst at it, this also create the folder <package directory>/inst/include. If you have specified no attributes, anywhere, then compileAttributes() does not create these directories.
In order to get rid of this warning, create the <package directory>/inst/include.
For more on attributes, see Rcpp attributes vignette.

R - unable to load devtools in R 3.2.0 under Windows XP 32 bit

When I try to load devtools in R
library(devtools)
I get a popup window that reports an msvcrt.dll error
RGui (32-bit) - [R Console]: Rgui.exe - Entry Point Not Found
The procedure entry point _chsize_s could not be located in the dynamic link library msvcrt.dll
and after closing the popup window, R reports the following error
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Program Files/R/R-3.2.0/library/git2r/libs/i386/git2r.dll':
LoadLibrary failure: The specified procedure could not be found.
Error: package or namespace load failed for ‘devtools’
Here is the R sessionInfo
sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows XP (build 2600) Service Pack 3
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] rversions_1.0.0 RCurl_1.95-4.6 memoise_0.2.1 digest_0.6.8 bitops_1.0-6 XML_3.98-1.1
In my search for solutions, I found one post that is very similar and which currently has one answer that did not work for me.
Any help is greatly appreciated.
I could not install devtools running the latest RStudio and R (as of July 2015) versions on Windows XP SP3. Apparently the latest version of git2r does NOT support windows XP.
My workaround was to install R-3.0.3 and RStudios 0.98.1103. With these versions, install.packages("devtools") works as expected.

Resources