Error installing rstan on R and cygwin on Windows 7 - r

I'm having trouble trying to install rstan at my server running R (version 3.0.1) using Windows 7 (64-bits).
I installed Rcpp and inline, and I got "* DONE (rstan)". However, when I run
fit <- stan(model_code = schools_code, data = schools_dat,iter = 1000, chains = 4)
I get the followig error:
Erreur dans compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-30~1.2/etc/x64/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-30~1.2/etc/x64/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
De plus : Message d'avis :
l'exécution de la commande 'C:/PROGRA~1/R/R-30~1.2/bin/x64/R CMD SHLIB file16bc2e56893.cpp 2> file16bc2e56893.cpp.err.txt' renvoie un statut 1
Does any of you know what to do?

My understanding is that Windows users are advised to use RTools rather than Cygwin compilers. Search with "RTools windows r" and also read the "R Extensions Manual".

Related

Do you know which Rtools version should be installed for R 3.6.3 in windows10?

I already installed Rtools35. But aftering install Rtools35, It continually occurs error in Rstudio.
This error is as follow :
extension<-ifelse(isWindows, ".dll", ".so")
dyn.load(paste0("D:/Platanus/CiPA_Rocde/CiPA-master/AP_simulation/models/newordherg_qNet",extension))
Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'D:/Platanus/CiPA_Rocde/CiPA-master/AP_simulation/models/newordherg_qNet.dll'
LoadLibrary failure: The specified module could not be found.
To solve above error, I need to check dubious things.
[1. Rtool version issue]
May be..... Does it occur error because of Rtool version?
I'm using R 3.6.3 version and Rtool35 version based on window10.
Do you know which Rtools version should be installed for R 3.6.3 in windows10(64bit)?
Can I install Rtools35? or Can I install Rtools40?
[1. Issue solution]
I checked #r2evans opinion mentioned as below, So I'll continually use Rtool35.
[2. R CMD SHLIB compile error in powershell in window10 issue]
To get .dll file, I compiled newordherg_qNet.c in powershell in window10.
Aftering compiling, It occurs error as following.
-Run error example
PS D:\Platanus\CiPA_Rocde\CiPA-master\AP_simulation\models> R CMD SHLIB newordherg_qNet.c
Invoke-History : 'SHLIB' It couldn't find location parameter permitting factor.
Location line : 1 character : 1
+ R CMD SHLIB newordherg_qNet.c
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-History],
ParameterBindingException
+ FullyQualifiedErrorId :
PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeHistoryCommand
Although I find solution associated with R CMD SHLIB issue, It is difficult to solve the issue. Do you have any idea to solve error?

Error when compiling RInside examples on Windows

I have an issue compiling the RInside examples on Windows.
In Rstudio, running
sourceCpp("C:/Users/Admin/Documents/R/win-library/3.5/RInside/examples/standard/rinside_sample0.cpp")
gives
fatal error: RInside.h: No such file or directory
From the command promt, running
cd C:\Users\Admin\Documents\R\win-library\3.5\RInside\examples\standard
make -f Makefile.win rinside_sample0
gives
Error in loadNamespace(name) : aucun package nommé 'Rcpp' n'est trouvé
Error in loadNamespace(name) : aucun package nommé 'RInside' n'est trouvé
Apparently these packages are not found, so I tried the following:
Ran this from the command line set R_HOME=C:\Program Files\R\R-3.5.2
Checked that Rtools and R dirs are present in the path
Modified the Makefile.win like so:
R_LIBS_USER := "C:/Users/Admin/Documents/R/win-library/3.5"
R_ARCH := --arch x64
But still getting the same errors. Any help? Thanks
EDIT: this answer might provide a solution by including this line of code somewhere
export R_LIBS_SITE=c:/R/site-library
However I don't know where to include it.
EDIT2 I have tried to reinstall Rcpp and RInside in both library locations (by running RStudio as admin)
remove.packages("Rcpp", lib = .libPaths())
remove.packages("RInside", lib = .libPaths())
install.packages("RInside", lib = .libPaths())
install.packages("Rcpp", lib = .libPaths())
library("RInside")
library("Rcpp")
In RStudio I still have the same error using sourceCpp, however, using the comand prompt and make approach I do get a different error:
make -f Makefile.win rinside_sample0
g++.exe: error: Files/R/R-3.5.2/library/RInside/include: No such file or directory
I suppose the space in the path is the problem " Files..." will try to reinstall R in a non-spaced path
Reinstalling R in a path without spaces, installing the latest packages, and setting R_HOME environment variable to the new installation folder C:\R\R-3.5.2 solved the problem.
remove.packages("Rcpp", lib = .libPaths())
remove.packages("RInside", lib = .libPaths())
install.packages("RInside", lib = .libPaths())
install.packages("Rcpp", lib = .libPaths())
library("RInside")
library("Rcpp")

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.

R data.entry is not working on OS X El Capitan

When I use R language, I can't use data entry:
$ R
> cheese = c(1,2,3)
> data.entry(cheese)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't open file: /usr/local/Cellar/r/3.2.2_1/R.framework/Resources/modules/R_de.so (No such file or directory)
Error in dataentry(odata, as.list(Modes)) : X11 is not available
In addition: Warning message:
running command ''/usr/bin/otool' -L '/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/modules/R_de.so'' had status 1
But I installed X11, XQuartz 2.7.7.
You need X11 support in order to use this function. Reinstall R with:
brew reinstall r --with-x11
It should then work as expected.
Installing 'R' from RStudio helped me in fixing this problem. I had installed 'R' using brew, therefore first uninstalled 'R' using command-
Atuls-MacBook-Pro:~ atulkaushik$ brew uninstall r
Then downloaded the appropriate package 'R-x.y.z.pkg' from RStudio. Though, this step helped me in running x11() on terminal, I was still not able to perform operations using this function.
m=matrix(1:81,9,9)
data.entry(m)
Error in .External2(C_dataentry, data, modes) :
unable to start data editor
In addition: Warning messages:
1: In dataentry(odata, as.list(Modes)) :
locale not supported by Xlib: some X ops will operate in C locale
2: In dataentry(odata, as.list(Modes)) : X cannot set locale modifiers
3: In dataentry(odata, as.list(Modes)) :
unable to create fontset --fixed-medium-r----120------
instead of invoking r shell through command 'r', I used LC_CTYPE=C R command
Atuls-MacBook-Pro:~ atulkaushik$ LC_CTYPE=C R
Now, when I execute
data.entry(m)
System will open a XQuartz window like -

require(RQuantLib) fails

I am trying to load RQuantLib but I get the following error:
> require(RQuantLib)
Loading required package: 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
I am pretty new to programming in general so I am not sure what this means. I am working in an Mac OS Maverick environment, I downloaded the latest version of RQuantLib (0.3.12) and the "R Package Installer" says it is installed. (I installed RQuantLib from the terminal using "R CMD INSTALL RQuantLib" as using install.packages() from within R did not work - it gave me an error saying QuantLib was not configured, although it was running fine in from the terminal.) I am running R from the R console. QuantLib works fine and so does Rcpp.
I checked the "NAMESPACE" document in the RQuantLib folder and it says:
import(methods)
importFrom(Rcpp, Rcpp.plugin.maker)
useDynLib(RQuantLib)
exportPattern("*.default")
export(
##--arrays.R
"oldEuropeanOptionArrays",
"EuropeanOptionArrays",
"plotOptionSurface",
##--asian.R
"AsianOption",
##--bermudan.R
"BermudanSwaption",
"summary.G2Analytic",
"summary.HWAnalytic",
"summary.HWTree",
"summary.BKTree",
##--bond.R
"ZeroCouponBond",
"ZeroPriceByYield",
"ZeroYield",
"FixedRateBond",
"FixedRateBondYield",
"FixedRateBondPriceByYield",
"FloatingRateBond",
"ConvertibleZeroCouponBond",
"ConvertibleFixedCouponBond",
"ConvertibleFloatingCouponBond",
"CallableBond",
"FittedBondCurve",
##--calendars.R
"isBusinessDay", "businessDay",
"isHoliday",
"isWeekend",
"isEndOfMonth",
"getEndOfMonth", "endOfMonth",
"adjust",
"advance",
"businessDaysBetween",
"getHolidayList", "holidayList",
"setCalendarContext",
##--dayCounter.R
"dayCount",
"yearFraction",
"setEvaluationDate",
##--discount.R
"DiscountCurve",
"plot.DiscountCurve",
##--implied.R
"EuropeanOptionImpliedVolatility",
"AmericanOptionImpliedVolatility",
"BinaryOptionImpliedVolatility",
##--option.R
"EuropeanOption",
"AmericanOption",
"AmericanOption.default",
"BinaryOption",
"BarrierOption"
)
S3method("plot", "Option")
S3method("print", "Option")
S3method("summary", "Option")
S3method("plot", "Bond")
S3method("print", "Bond")
S3method("summary", "Bond")
If I try to specify the path where the Terminal wrote that it installed RQuantLib while requiring it I get the following error:
> require('RQuantLib', lib.loc = "C:/Users/dealmer/Library/R/3.1/library/RQuantLib/libs")
Loading required package: RQuantLib
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
no library trees found in 'lib.loc'
So, do I need to move something from there to where the other R libraries are? (There is already a folder named "RQuantLib" in the folder where the other R library folders are, that's where I found the NAMESPACE doc for example) The path that the Terminal gave me I can't follow in the Finder window however because it doesn't show the "Library" folder and I don't know how to make it do that.)
This is what .libPaths() gives me:
> .libPaths()
[1] "/Users/dealmer/Library/R/3.1/library"
[2] "/Library/Frameworks/R.framework/Versions/3.1/Resources/library"
The R libraries are in [2].
I've tried googling but I can't find anything that seems helpful. Any help will be very appreciated. Thank you
- Dom
I think the issue is that on Linux we have quantlib-config in the $PATH:
edd#max:~$ quantlib-config --help
Usage: quantlib-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] \
[--libs] [--cflags]
edd#max:~$ quantlib-config --version
1.4
edd#max:~$
I don't own an OS X box, so I depend on someone like you help with a better configure setup. It should just work if you copy (or soft-link) quantlib-config into your path (eg /usr/local/bin), or adjust $PATH otherwise to include the directory it is in.
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!

Resources