简体   繁体   English

如何将全局环境中的列表数据放入列表中

[英]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.我们可以将mgetls一起使用,并指定以“ 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.

相关问题 如何将命名列表的内容加载到全局环境中? - How to load the content of a named list into global environment? 如何列出全局环境中的所有函数和值 - how to list all functions and values in global environment 如何从环境中获取数据帧列表,以便稍后使用lapply()魔术? - how to get list of data frames out of the environment for later lapply() magic? 如何使用值中的名称列表从全局环境调用数据框 - How to call data frames from Global environment using list of names in values 如何将全局环境中的数据表作为元素分配到列表 R 中(x 中的错误:下标越界) - How to assign data table from global environment as elements into list R (Error in x : subscript out of bounds) 如何列出我的全局环境中的所有数据框? - How can I make a list of all dataframes that are in my global environment? 如何将列表元素导入全局工作空间 - How to get list elements to global workspace R:如何摆脱存储在全局环境中的默认数据和值 - R: How to get rid of default data and values stored in global environment 从全局环境中选择数据框并将其导入到列表中 - Select and import dataframes into a list from the global environment 在全局环境中命名并放置列表的每个元素 - name and place each element of a list in Global Environment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM