将数据帧列表转换为R中的单个数据帧 [英] Converting a list of data frames into individual data frames in R

查看:136
本文介绍了将数据帧列表转换为R中的单个数据帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索高低,我认为是一个简单的解决方案。



我有一个大的数据帧,我被分解因素。

eqRegions< - split(eqDataAll,eqDataAll $ SeismicRegion)



现在,按区域创建数据帧的列表对象;共有8个。我想通过列表循环使用另一个名称来创建单独的数据框。



我可以执行以下操作将列表项转换为单个数据框,但是我认为有一个循环机制,如果我有很多因素,速度很快。



testRegion1 < - eqRegions [[1]]



testRegion3< - eqRegions [[3]]



我可以手动执行上述,它很好地处理它,但如果我有很多地区,效率不高。我想做的是相当于以下内容:

  for(i in 1:length(eqRegions)){
region [i]< - as.data.frame(eqRegions [[i]])
}

我认为关键是在循环之前定义区域,但是它会自动覆盖而不会递增。非常感谢。

解决方案

尝试 list2env(eqRegions,envir = .GlobalEnv)


I have been searching high and low for what I think is an easy solution.

I have a large data frame that I split by factors.

eqRegions <- split(eqDataAll, eqDataAll$SeismicRegion)

This now creates a list object of the data frames by region; there are 8 in total. I would like to loop through the list to make individual data frames using another name.

I can execute the following to convert the list items to individual data frames, but I am thinking that there is a loop mechanism that is fast if I have many factors.

testRegion1 <- eqRegions[[1]]

testRegion3 <- eqRegions[[3]]

I can manually perform the above and it handles it nicely, but if I have many regions it's not efficient. What I would like to do is the equivalent of the following:

for (i in 1:length(eqRegions)) {
   region[i] <- as.data.frame(eqRegions[[i]])
}

I think the key is to define region before the loop, but it keep overwriting itself and not incrementing. Many thanks.

解决方案

Try list2env(eqRegions,envir=.GlobalEnv)

这篇关于将数据帧列表转换为R中的单个数据帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆