[英]deparse(substitute()) don't work as the way I want It to
Code to reproduce the problem: 代码重现问题:
data(iris)
L=list(data=iris)
print(deparse(substitute(L[[1]])))
[1] "L[[1]]"
I want the result to be "iris" instead of "L[[1]]", is there a way? 我希望结果是“虹膜”而不是“L [[1]]”,有没有办法?
L <- list(data=as.name("iris"))
L$data
And to actually retrieve the data: 并实际检索数据:
eval(L$data)
But what you should be doing, rather than playing around with eval
and deparse
, is storing the name of the dataset along with its contents: 但是你应该做的是,而不是使用
eval
和deparse
,而是存储数据集的名称及其内容:
L <- list(iris=iris)
names(L)
L
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.