Install RJulia package in R - r

I am trying to install RJulia package on windows:
Julia Version: 0.4
R Version: 3.2.1
RStudio Version: 0.99.467
You may find the relevant R code:
library(devtools)
Sys.setenv(JULIA_SRC="C:/Users/user/AppData/Local/Julia-0.4.0-rc1")
Sys.setenv(LD_LIBRARY_PATH=":/Users/user/AppData/Local/Julia-0.4.0-rc1/lib/julia")
devtools::install_github("armgong/RJulia", ref="0.4")# or ref="0.4" if using Julia v0.4
but I am getting the following error:
julia: not found
julia: not found
gcc -m32 -I"C:/PROGRA~1/R/R-32~1.1/include" -DNDEBUG -I/../../src -I/../../src/support -I/../include -I/../include/julia -D_WIN32_WINNT=0x0600 -I"d:/RCompile/r-compiling/local/local320/include" -O3 -Wall -std=gnu99 -mtune=core2 -c Julia_R.c -o Julia_R.o
Julia_R.c:13:19: fatal error: julia.h: No such file or directory
compilation terminated.
make: *** [Julia_R.o] Error 1
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="rjulia.dll" OBJECTS="Julia_R.o R_Julia.o dataframe.o embedding.o"' had status 2
ERROR: compilation failed for package 'rjulia'
Any advice is appreciated!

I re-installed the latest version of RStudio 0.99.484 and re-configured the system PATH following #rawr advice (I had two installation paths of julia v.0.4 and v.0.3.11 and I kept the stable version) and it seems to work.

Related

R package source install, no compiler

I am trying to install some packages from source on a linux (RHEL) server. But whenever the package requires some C++ compilation it fails.
For example, I try to install Ckmeans.1d.dp package. If I call R CMD INSTALL Ckmeans.1.dp_4.2.1.tar.gz I get the following output (truncated) where you can see the compiler is omitted.
...* installing *source* package ‘Ckmeans.1d.dp’ ...
** libs
I/usr/include/R -DNDEBUG -I/usr/local/include -c Ckmeans.1d.dp.cpp -o Ckmeans.1d.dp.o
make: I/usr/include/R: Command not found
...
-shared -L/usr/local/lib64 -o Ckmeans.1d.dp.so Ckmeans.1d.dp.o Ckmeans.1d.dp_main.o dynamic_prog.o fill_SMAWK.o fill_log_linear.o fill_quadratic.o select_levels.o weighted_select_levels.o -L/usr/lib64/R/lib -lR
/bin/sh: line 2: -shared: command not found
make: *** [Ckmeans.1d.dp.so] Error 127
ERROR: compilation failed for package ‘Ckmeans.1d.dp’
I am currently stuck with a server that only has R 3.1.1 and I do not have admin privileges. The $Rhome/etc/Makeconf has CXX and CC defined. I have also verified g++ and gcc are installed.
What could be happening here?
Invariably an environment variable with an 'empty' value gets expanded. Maybe (just guessing here) the package would use C++11, so $(CXX11} -shared gets expanded and ... becomes -shared and an error is triggered.
Look at the R settings, eg via less $(R HOME)/etc/Makevars and see what it expects.
I think you can get by, if you must, installing gcc et al below, say, ~/bin. Some packages will require a compiler...

rpy2 installation error in Ubuntu

I've been trying to install rpy2 and install an R package from source.... I first installed rpy2 through binstar using conda. That seemed to install alright, but I got the error below when I tried compiling my R package from source.
So I uninstalled R and removed the rpy2 conda package. Then I re-installed R, and tried
pip install rpy2
But this fails to install and produces the following error:
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DR_INTERFACE_PTRS=1 -DHAVE_POSIX_SIGJMP=1 -DRIF_HAS_RSIGHAND=1 -DCSTACK_DEFNS=1 -DHAS_READLINE=1 -I./rpy/rinterface -I/usr/share/R/include -I/home/alex/anaconda/include/python2.7 -c ./rpy/rinterface/_rinterface.c -o build/temp.linux-x86_64-2.7/./rpy/rinterface/_rinterface.o
In file included from /usr/include/signal.h:28:0,
from ./rpy/rinterface/_rinterface.c:51:
/usr/include/features.h:374:25: fatal error: sys/cdefs.h: No such file or directory
# include <sys/cdefs.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
I imagine that the conda package I installed the first time ran into a similar problem, but it was only uncovered by trying to compile the R package from source? It complained about the same cdefs.h file...
Happy to give any more details that are needed to debug
I've been building out conda packages for R and related packages (include rpy2). Eventually they will be in the default conda repos, but until then, you can get it with conda install -c asmeurer rpy2 (this will also install and use my build of R itself).
A simple solution that worked for me was to just do sudo apt-get install python-rpy2. It worked flawlessly (assuming you already have R installed). And this way you don't need anaconda

How to get Rcpp to work?

I cannot get Rcpp to work on Windows 8.1. When I run the following minimal example, I get an error.
> library(Rcpp)
> evalCpp("1 + 1")
g++ -m64 -I"C:/R/R-31~1.0/include" -DNDEBUG -I"C:/R/R-3.1.0/library/Rcpp/include" -
I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c file11dc2120723d.cpp -o
file11dc2120723d.o g++: not found make: *** [file11dc2120723d.o] Error 127 Warning message: running
command 'make -f "C:/R/R-31~1.0/etc/x64/Makeconf" -f "C:/R/R-31~1.0/share/make/winshlib.mk"
SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="sourceCpp_97232.dll" WIN=64 TCLBIN=64
OBJECTS="file11dc2120723d.o"' had status 2
Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput, :
Error 1 occurred building shared library.
The two first entries in my path are:
PATH=c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin;
R is installed in a directory C:\R\R-3.1.0
Rtools is in the directory C:\R\Rtools
Some additional information:
> library(devtools)
> find_rtools(T)
Scanning path...
ls : c:\Rtools\bin\ls.exe
Scanning registry...
Found c:/Rtools for 3.1
VERSION.txt
Rtools version 3.1.0.1942
[1] TRUE
> has_devel()
"C:/R/R-31~1.0/bin/x64/R" --vanilla CMD SHLIB foo.c
gcc -m64 -I"C:/R/R-31~1.0/include" -DNDEBUG -I"d:/RCompile/CRANpkg/extralibs64/local/include"
O2 -Wall -std=gnu99 -mtune=core2 -c foo.c -o foo.o
gcc: not found
make: *** [foo.o] Error 127
Warning message:
running command 'make -f "C:/R/R-31~1.0/etc/x64/Makeconf" -f "C:/R/R-31~1.0/share/make/winshlib.mk"
SHLIB="foo.dll" WIN=64 TCLBIN=64 OBJECTS="foo.o"' had status 2
Error: Command failed (1)
> system('g++ -v')
Warning message:
running command 'g++ -v' had status 127
Unsure if you have solved your problem but it appears you don't have gcc or g++ installed. For windows you can get these tools with MinGW.
Install MinGW which you can donwload from here. The homepage for information is here
Once you have it installed MinGW, you can open the 'MinGW Installation Manager' and install the bin and dev for 'mingw32-gcc-g++'.
You must then update your PATH environmental variable to include 'C:\MinGW\bin' and 'C:\MinGW\msys\1.0\bin'.
Restart your R session, couldn't hurt to also reinstall 'Rcpp', and tryrequire(Rcpp); evalCpp("1 + 1") again.
I had this problem while trying to call C-code directly. Switching from the function system() to system2() solved it immediately.
I got that fix by installing RTools and adding RBuildTools to the path:
Sys.setenv("PATH" = paste(Sys.getenv("PATH"),
"C:\\RBuildTools\\3.4\\bin",
"C:\\RBuildTools\\3.4\\mingw_32",
"C:\\RBuildTools\\3.4\\mingw_64", sep = ";"))
I don't understand these things clearly but #cdeterman solutions was not working for building my package while its example evalCpp("1 + 1") did.

Why has my R devtools package load failed?

I am trying to create my first package using the instructions on the hadley devtools wiki. I am using Windows 7 Professional, I have loaded R-tools 3.1, and I am using R 3.0.2. I get the error below when I run the has_devel() command and I do no know why. Does anyone know how I can successfully install devtools given the error below.
has_devel()
"C:/PROGRA~1/R/R-30~1.2/bin/x64/R" --vanilla CMD SHLIB foo.c
Error: Command failed (1)
> traceback()
6: stop("Command failed (", status, ")", call. = FALSE)
5: system_check(r_path, options, c(r_env_vars(), env_vars), ...)
4: force(code)
3: in_dir(path, system_check(r_path, options, c(r_env_vars(), env_vars),
...))
2: R("CMD SHLIB foo.c", tempdir())
1: has_devel()
There is an existing related question, except in that example R is run on MAC OSX (The check for successful devtools load (has_devel) fails).
My Rtools installation was not complete.
I re-installed the most recent version of Rtools from CRAN (http://cran.rstudio.com/). I re-installed devtools using the instructions supplied by Hadley Wickham (http://adv-r.had.co.nz/Philosophy.html) and the error was fixed, has_devel() returned TRUE.
has_devel()
"C:/PROGRA~1/R/R-30~1.2/bin/x64/R" --vanilla CMD SHLIB foo.c
gcc -m64 -I"C:/PROGRA~1/R/R-30~1.2/include" -DNDEBUG -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -std=gnu99 -mtune=core2 -c foo.c -o foo.o
gcc -m64 -shared -s -static-libgcc -o foo.dll tmp.def foo.o -Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/PROGRA~1/R/R-30~1.2/bin/x64 -lR
[1] TRUE
see here for the same issue https://github.com/hadley/devtools/issues/234
(solution provided by hadley, running the script in this gist https://gist.github.com/hadley/4506250)
I have installed first time to a directory C:\Apps\Rtools without checking the environmental variable add step during installation. But, I have manually added the path into the PATH variable. Then, I had the same problem.
Then I reinstalled to the default directory C:\Rtools and this time I checked the environmental variable add step during installation. Then it worked.

compiling package with Rcpp outside of R-Studio in Windows

I've successfully build my own package with Rcpp in R-Studio. However, when building the package in the Windows console, there are some error messages complaining file missing of R.h.
I set the path and R_Home environments with
SET PATH=D:\RTools\gcc-4.6.3\bin;D:\R3\bin;D:\RTools\bin;
SET R_HOME=D:\R3\
And the build command is
R CMD INSTALL --byte-compile --build mypkg
Below are the compiling error messages:
g++ -m32 -I"/include" -DNDEBUG -I"D:/R3/library/Rcpp/include" -I"d:
/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c Rcpp
Exports.cpp -o RcppExports.o
In file included from D:/R3/library/Rcpp/include/Rcpp.h:27:0,
from RcppExports.cpp:4:
D:/R3/library/Rcpp/include/RcppCommon.h:35:15: fatal error: R.h: No su
ch file or directory
compilation terminated.
You are missing an include for R.h, as the error says.
And if you look at your compile line, the statement
-I"/include"
is wrong relative to your stated R_HOME in D:/R3
You need to check your setup, somehow you confused R from using the correct include directory.
Rcpp builds just fine on Windows, you can even check by submitting your package to the win-builder service.

Resources