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?

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to