Installing R Interface for Ipopt - r

I have exactly the same problem as the poster here, unfortunately no solution is provided on that link.
I built and installed IPOPT (version 3.12.6) on Windows 7 (64bit) with Cygwin, but I cannot seem to get the R interface to work. All commands (configure, make, make install, make test) were executed without error.
When I try to build the R interface from RStudio, I tried using both the code in the "build" folder as well as the code in the main directory. I get the following errors:
`>install.packages("C:/cygwin64/home/Ipopt-3.12.6/build/Ipopt/contrib/RInterface",
repos=NULL, type="source")
Error:
cygwin64/home/Ipopt-3.12.6/build/Ipopt/contrib/RInterface/DESCRIPTION'
Not using the build directory:
`>install.packages("C:/cygwin64/home/Ipopt-3.12.6/Ipopt/contrib/RInterface", repos=NULL, type="source")
Error:
installing source package 'ipoptr' ...
** libs
*** arch - i386 Warning: running command 'make -f "Makevars.win" -f "C:/Users/~1/DOCUME~1/R/R-33~1.1/etc/i386/Makeconf" -f
"C:/Users/~1/DOCUME~1/R/R-33~1.1/share/make/winshlib.mk"
SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)'
SHLIB="ipoptr.dll" ' had status 127 ERROR: compilation failed for
package 'ipoptr'
* removing 'C:/Users/Documents/R/R-3.3.1/library/ipoptr' Warning in install.packages : running command
'"C:/Users/~1/DOCUME~1/R/R-33~1.1/bin/x64/R" CMD INSTALL -l
"C:\Users\Documents\R\R-3.3.1\library"
"C:/cygwin64/home/Ipopt-3.12.6/Ipopt/contrib/RInterface"' had status 1
Warning in install.packages : installation of package
‘C:/cygwin64/home/Ipopt-3.12.6/Ipopt/contrib/RInterface’ had non-zero
exit status
Does anyone know what I could do to resolve this?
EDIT: After installing RTools and adding it to my PATH I get ipoptr.cpp:22:34: fatal error: IpIpoptApplication.hpp: No such file or directory
#include "IpIpoptApplication.hpp", i.e. it seems that ipoptr.cpp cannot find IpIpoptApplication.hpp (which is in a subdirectory of the build folder) and later on in the error still the same Warning: running command 'make -f "Makevars.win" -f ' had status 2.... Copying this file over to the location of ipoptr.cpp moves the error one file further to another similar file that it cannot find. I suspect it cannot find these files because of something being wrong with my makevars.win file (I suspect that that's the file that should point to the currently missing files). Does anyone have an idea what this could be?
EDIT 2: Might it have to do with the comment here indicating that in some cases LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$IPOPTDIR/build/lib should be set? How do I do this? Should this be done in R or cygwin?

Related

syntax error near unexpected token - R package Install

I am trying to install an R package along with its dependencies. But it is throwing error.
$ install.packages(rvest_0.3.5.tar.gz, dependencies=True)
-bash: syntax error near unexpected token `rvest_0.3.5.tar.gz,'
I am new to R please help me how can I download this along with it dependencies.
Before this, I tried following
$ R CMD INSTALL rvest_0.3.5.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library’
ERROR: dependencies ‘httr’, ‘magrittr’, ‘selectr’ are not available for package ‘rvest’
But it failed with dependent packages are missing error. And obviously it is cumbersome to install the dependent packages manually. Hence I tried package.install
You need to run it with quotes and capital TRUE:
install.packages("rvest_0.3.5.tar.gz", dependencies = TRUE)
Note this will only work if you have unix-like system and the file is located in your current working directory (check with running getwd() from your R session). Otherwise you need to provide full path to the file (like "~/somefolder/mydata/rvest_0.3.5.tar.gz").
If you run Windows, then you need .zip file instead of .tar.gz.
If you are connected to internet, just run:
install.packages("rvest")

Error in installing car package in R

While installing "car" package in Rstudio in Ubuntu, I faced an error saying that dependencies "nloptr","lme4" and one more, are not installed.
So I started installing "nloptr" but I faced this error-
configure: Need to download and build NLopt
trying URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Error in download.file(url = "http://ab-initio.mit.edu/nlopt/nlopt-
2.4.2.tar.gz", :
cannot open URL 'http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz'
Execution halted
/bin/tar: This does not look like a tar archive
gzip: stdin: unexpected end of file
/bin/tar: Child returned status 1
/bin/tar: Error is not recoverable: exiting now
Warning message:
In untar(tarfile = "nlopt-2.4.2.tar.gz") :
'/bin/tar -xf 'nlopt-2.4.2.tar.gz'' returned error code 2
configure: Starting to install library to
/tmp/RtmpSeLv7g/R.INSTALL18a67910d582/nloptr/nlopt-2.4.2
./configure: line 3325: cd: nlopt-2.4.2: No such file or directory
System hangs after last line and when I restart after some time, "nloptr" is not installed and hence I am unable to install "car" package.
Please help me. Thanks in advance.
I was encountering the same problem under R (pure R 3.2.3 on Linux Debian). I was first blocked by another issue during the same installation : the installation process failed to lock directory ~/.../R/x86_64.../3.2 and suggested to remove ~/.../R/x86_64.../3.2/00LOCK-nloptr . I did it, restart the car package installation, and then it blocked at the same point: it needs nlopt.h.
So, I installed libnlopt-dev (sudo apt-get install libnlopt-dev) and re-restart the car installation ... and then it worked.
Ok, this is under linux, but perhaps should you try to focus on installing something about NLOPT under windows.
Good luck.

error using R package brms

I would like to use the R package brms, but I get an error that I do not manage to interpret. It might have to do with Rtools, which is however installed on my computer.
This is an example from the brms package:
fit1 <- brm(count ~ log_Age_c + log_Base4_c * Trt_c
+ (1|patient) + (1|visit) + (1|obs),
data = epilepsy, family = poisson(),
prior = c(set_prior("student_t(5,0,10)", class = "b"),
set_prior("cauchy(0,2)", class = "sd")))
And this is the error I get:
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created!
c:/Rtools/mingw_64/bin/g++: not found
make: *** [file202834c75e9.o] Error 127
Warning message:
l'exécution de la commande 'make -f "C:/PROGRA~1/R/R-33~1.0/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-33~1.0/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file202834c75e9.dll" WIN=64 TCLBIN=64 OBJECTS="file202834c75e9.o"' renvoie un statut 2
In addition: Warning message:
running command 'C:/PROGRA~1/R/R-33~1.0/bin/x64/R CMD SHLIB file202834c75e9.cpp 2> file202834c75e9.cpp.err.txt' had status 1
Thanks for your help
Indeed, it is a problem with Rtools. What does system("g++ -v") give you? If it is status 127, Rtools cannot be found by R. Most likely, you haven't checked the box during Rtools installation where you were asked to amend the system path. I suggest that you unintall Rtools and install it again making sure to check the box. Please also verify that you are using the correct version of Rtools compatible with your R version.
I had a similar problem with my installation of rstan. The problem occurred with RTools33. Installing RTools34 seemed to fix the problem, although I now get the following warning:
In find_rtools() :
WARNING: Rtools 3.4 found on the path at c:/Rtools is not compatible with R 3.3.1.
Please download and install Rtools 3.3 from http://cran.r-project.org/bin/windows/Rtools/, remove the incompatible version from your PATH, then run find_rtools().
So far this warning appears benign.
If none of the other answers solve this issue, go into your R distribution and open
R-{version}\etc\x64\Makeconf
and change BINPREF on line 19 to whatever the path to your mingw_64\bin directory is.
To fix this error:" c:/Rtools/mingw_64/bin/g++: not found" I located RBuildTools folder on the C: drive, found the g++ file in the bin folder, copied the mingw_64 folder (or wherever your g++ file is located), created an Rtools folder on C: and pasted the mingw_64 folder. This will create the C:/Rtools/mingw_64/bin/ path you need to compile R code using the stan( ) function.
I followed the rStan wiki here on Windows Configuration.
Also instead of hacking Makevars in c:\ you can create your personal by following the instruction here.
In my %HOM%\.R\Makevars.win64 file I have
CXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function
BINPREF="H:/RTools/mingw_64/bin/"
This resolved my issue.

RQuantLib fails to load

I've recently updated all packages. Now RQuantLib fails to load. What can I do? I've tried to remove and reinstall the package in version 0.3.12 both from CRAN and from the source file, neither helps.
> library(RQuantLib)
Error : .onLoad failed in loadNamespace() for 'RQuantLib', details:
call: if (is.character(qc) && nchar(qc) > 1) {
error: missing value where TRUE/FALSE needed
In addition: Warning message:
running command 'bash -c 'type -p quantlib-config' 2>/dev/null' had status 1
Error: package or namespace load failed for ‘RQuantLib’
I'm working in RStudio with R 3.0.2 on Mac OS Mavericks. What can I do?
I had the same issue and after some hours of struggle I manage to use something not very rigorous but it works!
It seems that R has some issues evaluating system("bash -c 'type -p quantlib-config'").
After having installed QuantLib, typing the command bash -c 'type -p quantlib-config' in Terminal gives us the path of our quantlib-config which is for me /opt/local/bin/quantlib-config.
So I went back to my source folder for RQuantLib (version 0.4.0) and replaced qc in file R/inline.Rby:
qc <- as.character("/opt/local/bin/quantlib-config")
and rebuilt the package using the terminal command R CMD install RQuantLib/.
As I said, not very sexy but it works.
A restart of R and Rstudio is necessary.
Hope it helps the next ones and that this will be corrected in future versions.

Installing ggbiplot from github

I'm trying to install development version of ggbiplotfrom Github. During installation I'm getting the following error message:
library(devtools)
install_github("ggbiplot", "vqv")
Installing github repo(s) ggbiplot/master from vqv
Installing ggbiplot.zip from https://github.com/vqv/ggbiplot/zipball
Installing ggbiplot
* checking for file 'C:\Users\Muhammad Yaseen\AppData\Local\Temp\Rtmpsx4n5u\vqv-ggbiplot-2623d7c/DESCRIPTION' ... OK
* preparing 'ggbiplot':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* looking to see if a 'data/datalist' file should be added
* building 'ggbiplot_0.5.tar.gz'
cygwin warning:
MS-DOS style path detected: C:/Users/MUHAMM~1/AppData/Local/Temp/Rtmpsx4n5u/ggbiplot_0.5.tar.gz
Preferred POSIX equivalent is: /cygdrive/c/Users/MUHAMM~1/AppData/Local/Temp/Rtmpsx4n5u/ggbiplot_0.5.tar.gz
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Warning: invalid package 'Yaseen/R/win-library/2.14'
Error: ERROR: cannot cd to directory 'C:/Users/Muhammad'
Error: Command failed (1)
In addition: Warning message:
running command '"C:/PROGRA~1/R/R-214~1.2/bin/i386/R" CMD INSTALL C:\Users\MUHAMM~1\AppData\Local\Temp\Rtmpsx4n5u/ggbiplot_0.5.tar.gz --library=C:/Users/Muhammad Yaseen/R/win-library/2.14' had status 1
Any idea to figure out this problem. Thanks in advance for your help and time.
Edit
After downloading from Github, also tried
install.packages("vqv-ggbiplot-2623d7c.tar.gz", repos=NULL, type="source")
which produced this error message
Installing package(s) into ‘C:/Users/Muhammad Yaseen/R/win-library/2.14’
(as ‘lib’ is unspecified)
Error in untar2(tarfile, files, list, exdir) : unsupported entry type 'g'
Warning messages:
1: running command 'C:/PROGRA~1/R/R-214~1.2/bin/i386/R CMD INSTALL -l "C:/Users/Muhammad Yaseen/R/win-library/2.14" "vqv-ggbiplot-2623d7c.tar.gz"' had status 1
2: In install.packages("vqv-ggbiplot-2623d7c.tar.gz", repos = NULL, :
installation of package ‘vqv-ggbiplot-2623d7c.tar.gz’ had non-zero exit status
It's because your Rlib path has a space in it: C:/Users/Muhammad Yasseen/R/win-library/2.14.
See how in the first error log the warning message was
running command '"C:/PROGRA~1/R/R-214~1.2/bin/i386/R" CMD INSTALL
C:\Users\MUHAMM~1\AppData\Local\Temp\Rtmpsx4n5u/ggbiplot_0.5.tar.gz
--library=C:/Users/Muhammad Yaseen/R/win-library/2.14'
had status 1
In particular, the --library=C:/Users/Muhammad Yaseen/R/win-library/2.14.
This should be --library="C:/Users/Muhammad Yaseen/R/win-library/2.14" to deal with the space.
Using install.packages takes care of the quotes for you - see how your second warning message (when you used install.packages) was
running command 'C:/PROGRA~1/R/R-214~1.2/bin/i386/R CMD INSTALL
-l "C:/Users/Muhammad Yaseen/R/win-library/2.14"
"vqv-ggbiplot-2623d7c.tar.gz"' had status 1
The -l "C:/Users/Muhammad Yasseen/R/win-library/2.14" has quote marks around it, so you don't get the same error.
I had a quick look at the install-github sources, and it constructs the R CMD INSTALL command via:
paste("CMD INSTALL ", built_path, " --library=", .libPaths()[1], sep="")
See how it doesn't surround .libPaths()[1] by double quotes in case of spaces? I'd guess that's your problem.
As to a fix - there seems to be an error using install.packages() on a tar file generated by git (as reported here). So, you can either:
change your R library location to somewhere without spaces
unzip the .tar.gz file (I don't know what software does this on Windows) and install from the extracted directories rather than the .tar.gz.
You can't unzip the .tar.gz because it cleans up that file quicker than you can grab it (I've watched it appear and get deleted again). Correct me if I'm wrong, but I also can't get devtools from github for teh same reason :S

Resources