Having issues in installation of RWeka - r

I have been trying to install RWeka for R through ipython notebook, but am getting errors. I have ubuntu 16.10
I have tried the following commands
sudo R CMD javareconf
sudo R
install.packages("rJava",type="source")
"Installing package into ‘/home/shahan/R/x86_64-pc-linux-gnu-
library/3.3’
(as ‘lib’ is unspecified)
Content type 'application/x-gzip' length 656615 bytes (641 KB)
downloaded 641 KB
* installing *source* package ‘rJava’ ...
* package ‘rJava’ successfully unpacked and MD5 sums checked
warning: [options] bootstrap class path not set in conjunction with -
source 1.4
1 warning
/usr/lib/jvm/java-7-openjdk-amd64/jre/../bin/jar fc JRI.jar org
libjri.so
make[2]: Leaving directory
'/tmp/RtmpDMwK9H/R.INSTALL4a885e7a4476/rJava/jri/src'
rm -f libjri.so
cp src/libjri.so libjri.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/../bin/javac -target 1.4 -source
1.4 -classpath src/JRI.jar -d examples examples/rtest.java
warning: [options] bootstrap class path not set in conjunction with -
source 1.4
Note: examples/rtest.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 warning
/usr/lib/jvm/java-7-openjdk-amd64/jre/../bin/javac -target 1.4 -source
1.4 -classpath src/JRI.jar -d examples examples/rtest2.java
warning: [options] bootstrap class path not set in conjunction with -
source 1.4
Note: examples/rtest2.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 warning
make[1]: Leaving directory
'/tmp/RtmpDMwK9H/R.INSTALL4a885e7a4476/rJava/jri'
installing via 'install.libs.R' to /home/shahan/R/x86_64-pc-linux-gnu-
library/3.3/rJava
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (rJava)
The downloaded source packages are in
‘/tmp/RtmpPksP2c/downloaded_packages’ "
install.packages("RWeka")
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot download all files
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 0 != reported length 415763
Warning in download.packages(pkgs, destdir = tmpd, available =
available, :
download of package ‘RWeka’ failed
* installing *source* package ‘RWekajars’ ...
** package ‘RWekajars’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
No man pages found in package ‘RWekajars’
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (RWekajars)
The downloaded source packages are in
‘/tmp/RtmpPksP2c/downloaded_packages’ "
Finally when i run
library("RWeka")
I get the below error. Any help would be appreciated.
"Error: package or namespace load failed for ‘RWeka’
Traceback:
1. library("RWeka")
2. stop(gettextf("package or namespace load failed for %s",
sQuote(package)),
. call. = FALSE, domain = NA)"

You could follow this instructions:
$ cd ~/
$ sudo -i
$ apt-get install r-cran-rjava
$ apt-get update
$ apt-get install openjdk-8-jdk
(version 8 seems to be bug free!)
$ rm -rf /usr/lib/jvm/default-java
(I personally did not have the default-java file, but you can check if it exists on your machine)
$ ln -s /usr/lib/jvm/java-8-openjdk-amd64/ /usr/lib/jvm/default-java
$ R CMD javareconf
$ R
$ install.packages(“RWeka”)

Related

Unable to install magrittr

Got a new company laptop and tried to install tidyr or installr, but it always fails because of magrittr.
If I want to install this package directly I'm getting the following error code:
* installing *source* package 'magrittr' ...
** package 'magrittr' successfully unpacked and MD5 sums checked
** libs
*** arch - i386
Warning: running command 'make -f "C:/PROGRA~1/R/R-33~1.1/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-33~1.1/share/make/winshlib.mk" SHLIB="magrittr.dll" OBJECTS="pipe.o utils.o"' had status 127
ERROR: compilation failed for package 'magrittr'
* removing 'C:/Users/xxxx/Documents/R/win-library/3.3/magrittr'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-33~1.1/bin/x64/R" CMD INSTALL -l "C:\Users\xxxx\Documents\R\win-library\3.3" C:\Users\xxxx\AppData\Local\Temp\1\RtmpMHlNI9/downloaded_packages/magrittr_2.0.1.tar.gz' had status 1
Warning in install.packages :
installation of package ‘magrittr’ had non-zero exit status
I don't have admin privileges on this computer and could imagine that this could be the source of the problem, but I'm not sure.
What I tried:
Changed folder for libraries
Reinstalled all libraries
Tried different cron repos
Tried to install it on this way: install.packages("magrittr", update.packages(checkBuilt = TRUE))
Always the same error.
Is there any other way to install it?
Installing an archived version from source will work.
install.packages("cran.r-project.org/src/contrib/Archive/magrittr/…", repos = NULL, type="source")
You can utilize conda to install it:
conda install -c r r-magrittr
Reference:
https://anaconda.org/r/r-magrittr

Error message when trying to install rJava

I am trying to install rJava but it is not working. No matter which version of Java I install, I always get the same error. I already tried to install previous Java versions but that is not working. I also tried to set JAVA_HOME to the JDK folder but nothing seems to work. I am using Windows10.
Code and error:
> install.packages("rJava")
Installing package into ‘C:/Users/x/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is later:
binary source needs_compilation
rJava 0.9-12 0.9-13 TRUE
installing the source package ‘rJava’
trying URL 'https://cran.rstudio.com/src/contrib/rJava_0.9-13.tar.gz'
Content type 'application/x-gzip' length 664898 bytes (649 KB)
downloaded 649 KB
* installing *source* package 'rJava' ...
** package 'rJava' successfully unpacked and MD5 sums checked
** using staged installation
Generate Windows-specific files (src/jvm-w32) ...
make: Entering directory '/cygdrive/c/Users/x/AppData/Local/Temp/RtmpQffZ3r/R.INSTALL35acefc1be9/rJava/src/jvm-w32'
C:/RBuildTools/3.5/mingw_64/bin/dlltool --as C:/RBuildTools/3.5/mingw_64/bin/as --input-def jvm64.def --kill-at --dllname jvm.dll --output-lib libjvm.dll.a
C:/RBuildTools/3.5/mingw_64/bin/gcc -O2 -c -o findjava.o findjava.c
C:/RBuildTools/3.5/mingw_64/bin/gcc -s -o findjava.exe findjava.o
make: Leaving directory '/cygdrive/c/Users/x/AppData/Local/Temp/RtmpQffZ3r/R.INSTALL35acefc1be9/rJava/src/jvm-w32'
Find Java...
JAVA_HOME=C:/PROGRA~1/Java/JDK18~1.0_2/jre
=== Building JRI ===
JAVA_HOME=C:/PROGRA~1/Java/JDK18~1.0_2/jre
R_HOME=C:/PROGRA~1/R/R-36~1.3
JDK has no javah.exe - using javac -h . instead
Creating Makefiles ...
Configuration done.
make -C src JRI.jar
make[1]: Entering directory '/cygdrive/c/Users/x/AppData/Local/Temp/RtmpQffZ3r/R.INSTALL35acefc1be9/rJava/jri/src'
C:/PROGRA~1/Java/JDK18~1.0_2/jre/bin/javac -h . -d . ../RList.java ../RBool.java ../RVector.java ../RMainLoopCallbacks.java ../RConsoleOutputStream.java ../Mutex.java ../Rengine.java ../REXP.java ../RFactor.java ../package-info.java
sh: C:/PROGRA~1/Java/JDK18~1.0_2/jre/bin/javac: No such file or directory
make[1]: *** [Makefile.all:41: org/rosuda/JRI/Rengine.class] Error 127
make[1]: Leaving directory '/cygdrive/c/Users/x/AppData/Local/Temp/RtmpQffZ3r/R.INSTALL35acefc1be9/rJava/jri/src'
make: *** [Makefile.all:19: src/JRI.jar] Error 2
**** WARNING: JRI could NOT be built
Set IGNORE=1 if you want to build rJava anyway.
ERROR: configuration failed for package 'rJava'
* removing 'C:/Users/x/Documents/R/win-library/3.6/rJava'
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
Thank you for your help!
I would not recommend installing rJava from sources, because it is entirely unnecessary and compiling packages on Windows requires much better knowledge of tools, Java and your system. Since you are using Windows, please install rJava from CRAN using
install.packages("rJava", type="win.binary")

Install Rmosek under 3.4.4 using macOS

I'd like to install the packages Rmosek with R 3.4.4 version.
I have this problem:
* installing *source* package ‘Rmosek’ ...
** package ‘Rmosek’ successfully unpacked and MD5 sums checked
Configuring for a UNIX-alike platform (sub-architecture: "")
Found package 'Matrix' version 1.2.14
*** No variable 'PKG_MOSEKHOME' in environment - see configure-vars (configure.vars) argument ***
*** No variable 'PKG_MOSEKHOME' in ./src/setup/Localsys.txt file ***
*** Shell command 'mosek' was not recognized - please validate your installation of MOSEK ***
*** >> PATH = /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/TeX/texbin:/opt/X11/bin:/opt/local/bin ***
ERROR: configuration failed for package ‘Rmosek’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rmosek’
Warning in install.packages :
installation of package ‘Rmosek’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/42/p9yl3yln6zn8dq_3zdd496kr0000gn/T/RtmpBe0vs2/downloaded_packages’
I solved my problem by this post: https://gist.github.com/mikelove/67ea44d5be5a053e599257fe357483dc#file-rmosek-L19
1) Download mosek from here:
https://www.mosek.com/downloads/
(I downloaded this to my ~/bin)
cd ~/bin
tar -xvf mosektoolslinux64x86.tar.bz2
2) Add this to your ~/.bashrc
export PATH=$PATH:/home/username/bin/mosek/8/tools/platform/linux64x86/bin
3) Get academic license:
https://www.mosek.com/products/academic-licenses/
Check email, put licsense file in ~/mosek
4) Install:
export PKG_MOSEKHOME=/home/username/bin/mosek/8/tools/platform/linux64x86
export PKG_MOSEKLIB=mosek64
Then in R:
install.packages("Rmosek", type="source", INSTALL_opts="--no-multiarch", repos="http://download.mosek.com/R/8")

downgrading a package in R

I recently installed the forecast package, using install.packages().
The latest version (6.1) has been successfully installed but I want to install the forecast package version 5.9. So I used :
install.packages('http://cran.rstudio.com/src/contrib/Archive/forecast/forecast_5.9.tar.gz', repos=NULL, type='source')
But when using library I get an error:
install.packages('http://cran.rstudio.com/src/contrib/Archive/forecast/forecast_5.9.tar.gz', repos=NULL, type='source')
Installing package into ‘C:/Users/.../Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/Archive/forecast/forecast_5.9.tar.gz'
Content type 'application/x-gzip' length 156982 bytes (153 KB)
downloaded 153 KB
* installing *source* package 'forecast' ...
** package 'forecast' successfully unpacked and MD5 sums checked
** libs
*** arch - i386
Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA~1/R/R-32~1.1/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-32~1.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="forecast.dll" OBJECTS="calcBATS.o calcTBATS.o etsTargetFunction.o etsTargetFunctionWrapper.o etscalc.o etspolyroot.o makeBATSMatrices.o makeTBATSMatrices.o updateMatrices.o updateTBATSMatrices.o"' had status 127
ERROR: compilation failed for package 'forecast'
* removing 'C:/Users/.../Documents/R/win-library/3.2/forecast'
* restoring previous 'C:/Users/.../Documents/R/win-library/3.2/forecast'
Warning in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) :
problem copying C:\Users\...\Documents\R\win-library\3.2\00LOCK-forecast\forecast\libs\x64\forecast.dll to C:\Users\...\Documents\R\win-library\3.2\forecast\libs\x64\forecast.dll: Permission denied
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.1/bin/x64/R" CMD INSTALL -l "C:\Users\...\Documents\R\win-library\3.2" "C:/Users/.../AppData/Local/Temp/RtmpQzO3Zp/downloaded_packages/forecast_5.9.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘C:/Users/.../AppData/Local/Temp/RtmpQzO3Zp/downloaded_packages/forecast_5.9.tar.gz’ had non-zero exit status
Here is the way to install forecast version 5.9(Its not a problem if you have forecast 6.1 already installed,it would install 5.9 separately meaning that you would see two forecast packages in the installed packages ).
Go to the link https://cran.r-project.org/src/contrib/Archive/forecast/
Download forecast 5.9(just click on it,it would start downloading the file.
Now open the R studio,click on install packages and change install from to : Package archive File(and just browse it to the location of zip file).And your package would be installed.
While using the forecast package in my case it didnt work(the function that uses forecast package) when both the forecast package where loaded.So i use forecast 5.9 making sure that 6.1 isnt loaded.
Hope that helps

Error when installing gpclib

R version 3.2.1
I downloaded gpclib_1.5-5.tar.gz from http://cran.r-project.org/web/packages/gpclib/index.html and attempted to install the package with
install.packages("D:/GIS/gpclib_1.5-5.tar.gz", repos = NULL, type = "source")
I get the error
* installing *source* package 'gpclib' ...
** package 'gpclib' successfully unpacked and MD5 sums checked
** libs
*** arch - i386
Warning: running command 'make -f "D:/R/R-3.2.1/etc/i386/Makeconf" -f "D:/R/R-3.2.1/share/make/winshlib.mk" SHLIB="gpclib.dll" OBJECTS="Rgpc.o gpc.o"' had status 127
ERROR: compilation failed for package 'gpclib'
* removing 'D:/R/R-3.2.1/library/gpclib'
Warning in install.packages :
running command '"D:/R/R-3.2.1/bin/x64/R" CMD INSTALL -l "D:\R\R-3.2.1\library" "D:/GIS/gpclib_1.5-5.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘D:/GIS/gpclib_1.5-5.tar.gz’ had non-zero exit status
How do I troubleshoot this?
Extra Information
I am ultimately trying to create heat maps, and am following this tutorial
http://spatialanalysis.co.uk/wp-content/uploads/2013/04/james_cheshire_ggplot_intro_blog.pdf
You'll need to install Rtools to install the R compiler libraries:
http://cran.r-project.org/bin/windows/Rtools/
Otherwise, R will have issues compiling from source code.

Resources