来源字符向量

时间:2015-08-10 18:10:42

标签: r

以下脚本运行良好。不过,我想知道是否有可能直接获取向量x。

x <- c("print (\"Hallo world\")", "print (\"(Just an example)\")")
temporary_file <- tempfile()
write(x, file = temporary_file )
source(temporary_file)

1 个答案:

答案 0 :(得分:2)

x <- c("print (\"Hallo world\")", "print (\"(Just an example)\")");
eval(parse(text=x));
## [1] "Hallo world"
## [1] "(Just an example)"