I installed rstan and when I call map2stan I get the error below:
> library(rstan)
> packageVersion("rstan", lib.loc = "C://TOOLS//R-3.4.0patched//library" )
[1] ‘2.16.2’
here's the call to map2stan
library(rethinking)
data(rugged)
d <- rugged
d$log_gdp <- log(d$rgdppc_2000)
dd <- d[ complete.cases(d$rgdppc_2000) , ]
dd.trim <- dd[ , c("log_gdp","rugged","cont_africa") ]
str(dd.trim)
m8.1stan <- map2stan(
alist(
log_gdp ~ dnorm( mu , sigma ) ,
mu <- a + bR*rugged + bA*cont_africa + bAR*rugged*cont_africa ,
a ~ dnorm(0,100),
bR ~ dnorm(0,10),
bA ~ dnorm(0,10),
bAR ~ dnorm(0,10),
sigma ~ dcauchy(0,2)
) ,
data=dd.trim )
here's the error
Warning message:
running command 'make -f "C:/TOOLS/R-34~1.0PA/etc/x64/Makeconf" -f "C:/TOOLS/R-34~1.0PA/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file29cc72047709.dll" WIN=64 TCLBIN=64 OBJECTS="file29cc72047709.o"' had status 127
ERROR(s) during compilation: source code errors or compiler configuration errors!
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! Warning message:
running command 'make -f "C:/TOOLS/R-34~1.0PA/etc/x64/Makeconf" -f "C:/TOOLS/R-34~1.0PA/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file344416f9304.dll" WIN=64 TCLBIN=64 OBJECTS="file344416f9304.o"' had status 127
In addition: Warning message:
running command 'C:/TOOLS/R-34~1.0PA/bin/x64/R CMD SHLIB file344416f9304.cpp 2> file344416f9304.cpp.err.txt' had status 1
Error in map2stan(alist(log_gdp ~ dnorm(mu, sigma), mu <- a + bR * rugged + :
Something went wrong, when calling Stan. Check any debug messages for clues, detective.
Compilation ERROR, function(s)/method(s) not created! Warning message:
running command 'make -f "C:/TOOLS/R-34~1.0PA/etc/x64/Makeconf" -f "C:/TOOLS/R-34~1.0PA/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="file344416f9304.dll" WIN=64 TCLBIN=64 OBJECTS="file344416f9304.o"' had status 127
>
Hmm, I installed rethinking library via http://xcelab.net/rm/software/ (it was not on CRAN) and ran the same code and didn't get any errors in my case. What's the Rtools, R, and OS type/version? Have you followed all installation instructions, e.g. if your OS is Windows, on https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Windows? Can you check that their eight school example in https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started runs fine?
Related
I am creating my first R package. One of the functions will be taking in a vcf file and outputing it formatted into the R env for further use. Here's the code below!
enter image description here
After I install the package this is what I get:
> devtools::install()
── R CMD build ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ checking for file 'C:\Users\raymu\OneDrive\Documents\R\LoF\myfirstpackage/DESCRIPTION' ...
─ preparing 'myfirstpackage':
E checking DESCRIPTION meta-information ...
Malformed maintainer field.
See section 'The DESCRIPTION file' in the 'Writing R Extensions'
manual.
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'Rcmd.exe' failed
---
Exit status: 1
stdout & stderr: <printed>
---
When I try to execute the function on a test vcf file there is no error but doesn't make anything in the environment
I tried devtools::check and got this but am unsure what it means
> devtools::check()
══ Documenting ═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
ℹ Updating myfirstpackage documentation
ℹ Loading myfirstpackage
Warning: Skipping NAMESPACE
✖ It already exists and was not generated by roxygen2.
══ Building ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Setting env vars:
• CFLAGS : -Wall -pedantic
• CXXFLAGS : -Wall -pedantic
• CXX11FLAGS: -Wall -pedantic
• CXX14FLAGS: -Wall -pedantic
• CXX17FLAGS: -Wall -pedantic
• CXX20FLAGS: -Wall -pedantic
── R CMD build ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ checking for file 'C:\Users\raymu\OneDrive\Documents\R\LoF\myfirstpackage/DESCRIPTION' (405ms)
─ preparing 'myfirstpackage':
E checking DESCRIPTION meta-information ...
Malformed maintainer field.
See section 'The DESCRIPTION file' in the 'Writing R Extensions'
manual.
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'Rcmd.exe' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Type .Last.error to see the more details.
> .Last.error
<system_command_status_error/rlib_error_3_0/rlib_error/error>
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'Rcmd.exe' failed
---
Exit status: 1
stdout & stderr: <printed>
---
Backtrace:
1. devtools::check()
2. withr::with_envvar(pkgbuild::compiler_flags(FALSE), action = "prefix", …
3. base::force(code)
4. pkgbuild::build(pkg$path, tempdir(), args = build_args, quiet = quiet, …
5. withr::with_temp_libpaths(rcmd_build_tools(options$cmd, c(options$path, …
6. base::force(code)
7. pkgbuild::rcmd_build_tools(options$cmd, c(options$path, options$args), …
8. pkgbuild::with_build_tools({ …
9. withr::with_path(rtools_path(), code)
10. base::force(code)
11. base::withCallingHandlers(callr::rcmd_safe(..., env = env, spinner = FALSE, …
12. callr::rcmd_safe(..., env = env, spinner = FALSE, show = FALSE, …
13. callr:::run_r(options)
14. base::with(options, with_envvar(env, do.call(processx::run, c(list(bin, …
15. base::with.default(options, with_envvar(env, do.call(processx::run, …
16. base::eval(substitute(expr), data, enclos = parent.frame())
17. base::eval(substitute(expr), data, enclos = parent.frame())
18. callr:::with_envvar(env, do.call(processx::run, c(list(bin, args = real_cmdargs, …
19. base::force(code)
20. base::do.call(processx::run, c(list(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout), …
21. (function (command = NULL, args = character(), error_on_status = TRUE, …
22. base::throw(new_process_error(res, call = sys.call(), echo = echo, …
23. | base::signalCondition(cond)
24. (function (e) …
25. asNamespace("callr")$err$throw(e)
I am expecting a formatted table in the Rstudio environment that can be utilized further by the user.
I have a separate script that I have developed and works great but want to transform it into a package for ease of use and deployment for my thesis research
Please let me know if there is any other info that I missed.
Drop the save line at the end of your function. Put return(tmp_vcf_data) or even simply tmp_vcf_data as the last line of your function. This way your function will return your formatted vcf file.
Then call your function and assign the output to an object. For example output <- load_vcf(inline).
When I run the string below in my command line, it works fine. But when I run it from R, it does not.
I run this:
>cmd <- "python -c 'import sys; import pandas; import scrublet; df = pandas.read_csv(\"C:\\Users\\User\\AppData\\Local\\Temp\\RtmpOmMtOp\\file383068ca4fa\"); scrub = scrublet.Scrublet(df); doublet_scores, predicted_doublets = scrub.scrub_doublets(); pandas.DataFrame(doublet_scores).to_csv(\"C:\\Users\\User\\AppData\\Local\\Temp\\RtmpOmMtOp\\file383068ca4fa.doubletScores\");'"
tmp <- system(cmd, intern=T)
Warning message:
In system(cmd, intern = T) :
running command 'python -c 'import sys; import pandas; import scrublet; df = pandas.read_csv("C:\Users\User\AppData\Local\Temp\RtmpOmMtOp\file383068ca4fa"); scrub = scrublet.Scrublet(df); doublet_scores, predicted_doublets = scrub.scrub_doublets(); pandas.DataFrame(doublet_scores).to_csv("C:\Users\User\AppData\Local\Temp\RtmpOmMtOp\file383068ca4fa.doubletScores");'' had status 1
I got error msg when converting tex to pdf using texi2pdf function in Rstudio.
tools::texi2pdf('test.tex')
and the error msg I got:
Error in system(paste(shQuote(texi2dvi), if (quiet) "--quiet" else "", :
(converted from warning) running command '"C:\CTEX\MiKTeX\miktex\bin\texi2dvi.exe" --quiet --pdf "test.tex" --max-iterations=20 -I "C:/Program Files/R/R-3.5.1/share/texmf/tex/latex" -I "C:/Program Files/R/R-3.5.1/share/texmf/bibtex/bst"' had status 1
1: tools::texi2pdf("test.tex")
2: texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, texi2dvi = texi2dvi, texinputs = texinputs, index = index)
3: system(paste(shQuote(texi2dvi), if (quiet) "--quiet" else "", if (pdf) "--pdf" else "", shQuote(file), extra), intern = TRUE, ignore.stderr = TRUE)
4: .signalSimpleWarning("running command '\"C:\\CTEX\\MiKTeX\\miktex\\bin\\texi2dvi.exe\" --quiet --pdf \"test.tex\" --max-iterations=20 -I \"C:/Program Files/R/R-3.5.1/share/texmf/tex/latex\" -I \"C:/Program Files/R/R
5: withRestarts({
.Internal(.signalCondition(simpleWarning(msg, call), msg, call))
.Internal(.dfltWarn(msg, call))
}, muffleWarning = function() NULL)
6: withOneRestart(expr, restarts[[1]])
7: doWithOneRestart(return(expr), restart)
I am running windows10, R version 3.5.1 , RStudio 1.1.463 and CTeX_2.9.2.164.
Anyone could help me with this problem? Thanks.
I have R, R Studio and R-tools installed on Windows 7.
I am trying to: cd into a directory and execute a command, this is what I am getting from R, it returns M, what does that mean ?
> system(paste("cmd.exe", input = "cd c:/Users/X123/Desktop/FASTLOAD/", "&& fastload < load_journey.fl > output.txt", sep=" "))
M
>
what am I doing wrong ? I never see the command executed, thanks!
I changed it from system() to shell() and it works now, but get a bunch of warning messages, is that ok or should I do something for them to go away ?
> shell(paste("cd c:/Users/X123/Desktop/FASTLOAD/ ", "&& fastload < load_journey.fl > output.txt", sep=" "))
Warning messages:
1: running command 'C:\Windows\system32\cmd.exe /c cd c:/Users/X123/Desktop/FASTLOAD/ && fastload < load_journey.fl > output.txt' had status 4
2: In shell(paste("cd c:/Users/X123/Desktop/FASTLOAD/ ", "&& fastload < load_journey.fl > output.txt", :
'cd c:/Users/X123/Desktop/FASTLOAD/ && fastload < load_journey.fl > output.txt' execution failed with error code 4
>
I'm getting an error when trying to connect (dbConnect()) from within R to MonetDB (using MonetDB.R). There is a (related SO question) and I also tryed the sugestions there ( (a) use MonetDB.R beta version 0.9.5 or (a) use the regular MonetDB.R but replace DBI package with an earlier version (0.2-7)) without success.
This is the code and errors:
library(MonetDB.R)
options( "monetdb.sequential" = TRUE )
setwd("C:/Users/lucas_000/Desktop/Curso R/importa_RAIS")
batfile <-
monetdb.server.setup(
database.directory = paste( getwd() , "/MonetDB", sep="") ,
monetdb.program.path =
ifelse(.Platform$OS.type == "windows" , "C:/Program Files/MonetDB/MonetDB5" , "" ) ,
dbname = "RAIS" , dbport = 50003
)
batfile <- "C:/Users/lucas_000/Desktop/Curso R/importa_RAIS/MonetDB/RAIS.bat"
dbname <- "RAIS"
dbport <- 50003
pid <- as.numeric(monetdb.server.start( batfile ))
# output indicates: MonetDB 5 server v11.17.21 "Jan2014-SP3"
db <- dbConnect( MonetDB.R() , "monetdb://localhost:5003/RAIS" , wait = TRUE )
Assertion Failed!
Program: C\:Program Files\RStudio\bin\x64\rsession.exe
File: mapi.c, Line 91
Expression: IS_INTEGER(port)
#Then RStudio displays an error: "R Session Aborted"
Sistem details:
Windows 8.0, on RStudio, Version 0.98.1062
> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
other attached packages:
[1] R.utils_1.33.0 R.oo_1.18.0 R.methodsS3_1.6.1 downloader_0.3
[5] RCurl_1.95-4.3 bitops_1.0-6 sqlsurvey_0.6-11 survey_3.30-3
[9] KernSmooth_2.23-12 MonetDB.R_0.9.4 digest_0.6.4 DBI_0.3.1
loaded via a namespace (and not attached):
[1] tools_3.1.1
Attempted solutions and respective errors:
a) TRYING TO INSTALL MonetDB.R_0.9.5.zip (beta version)
library(devtools)
remove.packages("MonetDB.R")
install_url("http://homepages.cwi.nl/~hannes/R/MonetDB.R_0.9.5.zip")
* installing *binary* package 'MonetDB.R' ...
cp: unknown option -- )
Try `/usr/bin/cp --help' for more information.
Aviso: execução do comando 'cp -R . "C:/Users/lucas_000/Documents/R/win- library/3.1/MonetDB.R" || ( tar cd - .| (cd "C:/Users/lucas_000/Documents/R/win-library/3.1/MonetDB.R" && tar -xf -))' teve status 1
ERROR: installing binary package failed
* removing 'C:/Users/lucas_000/Documents/R/win-library/3.1/MonetDB.R'
Error: Command failed (1)
b) Keeping the MonetDB.R regular version (cran) but changing the DBI to an earlier version (also sugested on SO):
remove.packages("DBI")
library(devtools)
install_url("cran.r-project.org/src/contrib/Archive/DBI/DBI_0.2-7.tar.gz")
library(DBI)
db <- dbConnect( MonetDB.R() , "monetdb://localhost:5003/RAIS" , wait = TRUE )
# gives same error as above,
Assertion Failed!
Program: C:Program Files\RStudio\bin\x64\rsession.exe
File: mapi.c, Line 91
Expression: IS_INTEGER(port)
#Then RStudio displays an error: "R Session Aborted"
MonetDB.R 0.9.5 has been released to CRAN. Windows binary distributions should be available shortly.
The error may have been in the line where you create the dbConnect.
Your code (incorrect port):
db <- dbConnect( MonetDB.R() , "monetdb://localhost:5003/RAIS" , wait = TRUE )
Correct code:
db <- dbConnect( MonetDB.R() , "monetdb://localhost:50003/RAIS" , wait = TRUE )
Another issue with this code may have been choosing dbport to be be 50 003; I believe the default is 50 000.