且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

转换格式为字符串形式的列表

更新时间:2023-11-29 12:28:52

如@missuse所建议,可以使用evalparse.后者将创建一个表达式,然后对其求值以返回列表对象.

As proposed by @missuse, you could use eval and parse. The latter will create an expression, which is then evaluated to return a list object.

以下是可重现的示例:

lst <- list(list(list(x = 123, y = "test")))
lst
eval(parse(text = as.character(lst[[1]])))

您还可以使用它来运行这个例子.

You could also use this to run code as shown in this example.