Gabor Grothendieck
2010-Jun-18 01:00 UTC
[R] Speeding up the transfer of a tcl character array to R
What is the best way to transfer a character array from tcl to R.
1. This works but its very slow if the tcl variable, r, is long:
n <- as.numeric(tclvalue(.Tcl("llength $r")))
sapply(seq(0, length = n), function(i) tclvalue(.Tcl(paste("lindex
$r", i))))
2. This also works and is fast but having to set r to itself seems
somewhat ugly:
as.character(.Tcl("set r $r"))
3. The following does not work as I want as it returns all the
elements of r as one big character string separated with spaces:
tclvalue("r")
Any alternatives?