Closed sckott closed 7 years ago
thanks
@jeroenooms not sure what's going wrong,
trying this, but:
install from sys
branch, then
library(sys)
library(phylocomr)
tf <- tempfile()
pf <- tempfile()
cat(c("campanulaceae/lobelia/lobelia_conferta", "cyperaceae/mapania/mapania_africana", "amaryllidaceae/narcissus/narcissus_cuatrecasasii"), file = tf, sep = "\n")
cat("(((((eliea_articulata,homalanthus_populneus)malpighiales,rosa_willmottiae),((macrocentrum_neblinae,qualea_clavata),hibiscus_pohlii)malvids),(((lobelia_conferta,((millotia_depauperata,(layia_chrysanthemoides,layia_pentachaeta)layia),senecio_flanaganii)asteraceae)asterales,schwenkia_americana),tapinanthus_buntingii)),(narcissus_cuatrecasasii,mapania_africana))poales_to_asterales;", file = pf, sep = "\n")
# check they're there
file.exists(tf, pf)
readLines(tf)
readLines(pf)
args <- sprintf("-t %s -f %s", tf, pf)
path <- file.path(
system.file("bin", .Platform$r_arch, package = "phylocomr"), "phylomatic")
out <- rawConnection(raw(0), "r+")
(res <- sys::exec_wait(path, args, std_out = out))
#> 8
rawToChar(rawConnectionValue(out))
#> "Cannot open phylogeny file\n"
The args
argument must be a character vector with args. Don't concat it into a string. Then it should work.
args <- c("-t", tf, "-f", pf)
interesting, ok. why wouldn't it also work as one string? just curious
Actually I thought that system2
works the same way, but apparently it doesn't. The args map directly to the argument vector from the executable. So in your case the executable would be run with only one big argument, containing spaces...
Als you might be able to simplify the code using exec_internal
:
tf <- tempfile()
pf <- tempfile()
cat(c("campanulaceae/lobelia/lobelia_conferta", "cyperaceae/mapania/mapania_africana", "amaryllidaceae/narcissus/narcissus_cuatrecasasii"), file = tf, sep = "\n")
cat("(((((eliea_articulata,homalanthus_populneus)malpighiales,rosa_willmottiae),((macrocentrum_neblinae,qualea_clavata),hibiscus_pohlii)malvids),(((lobelia_conferta,((millotia_depauperata,(layia_chrysanthemoides,layia_pentachaeta)layia),senecio_flanaganii)asteraceae)asterales,schwenkia_americana),tapinanthus_buntingii)),(narcissus_cuatrecasasii,mapania_africana))poales_to_asterales;", file = pf, sep = "\n")
# check they're there
file.exists(tf, pf)
readLines(tf)
readLines(pf)
args <- c("-t", tf, "-f", pf)
path <- file.path(
system.file("bin", .Platform$r_arch, package = "phylocomr"), "phylomatic")
out <- sys::exec_internal(path, args, error = FALSE)
rawToChar(out$stdout)
Thanks, that works.
Right, exec_internal
should be easier
fixed via #7
The problems with
sys
should be fixed now as of version 1.1 on CRAN.