[英]How to get a list data that are in global environment into a list
I am working on a list of.csv data which I have read in and keep the variables that i need for study.我正在处理我已读入的 .csv 数据列表,并保留我需要研究的变量。 During this process, I have build multiple data set with name xxx_101(PY_101, vB_101_FG_101, etc.) which store in global environment.
在此过程中,我构建了多个名为 xxx_101(PY_101、vB_101_FG_101 等)的数据集,这些数据集存储在全局环境中。 Now I want to put every new data set with ending _101 into a list.
现在我想将所有以 _101 结尾的新数据集放入一个列表中。 Is it a clever way to build that list other than type them in one by one?
除了一个一个地输入它们之外,这是构建该列表的聪明方法吗? Once I read them in to a list, I would like to rename the each list with their original data name.
一旦我将它们读入列表,我想用它们的原始数据名称重命名每个列表。 Is there a easy way to do that?
有没有简单的方法可以做到这一点?
I could do it one by one, but just feel there should be a better way to do.我可以一个一个地做,但只是觉得应该有更好的方法去做。 Thanks.
谢谢。
We can use mget
with ls
and specify the pattern
with "_101"
as the end ( $
) of the object name.我们可以将
mget
与ls
一起使用,并指定以“ pattern
"_101"
作为 object 名称结尾 ( $
) 的模式。 It would get the values of all those objects into a list
它会将所有这些对象的值放入
list
lst1 <- mget(ls(pattern = "_101$"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.