【发布时间】:2021-05-30 20:39:11
【问题描述】:
我使用 group_split() 函数将两个数据框(增长和投资)拆分为 40 个数据框(在荷兰的每个 COROP 区域拆分)。我的目标是合并每个 COROP 的拆分数据帧,这可以使用以下代码完成:
# COROP 1
CR01 <- cbind(growth_per_corop[[1]], investment_per_corop[[1]]) # merging growth and investment data for corop 1
CR01 <- CR01[-c(4:6)] # removing duplicate columns
# COROP 2
CR02 <- cbind(growth_per_corop[[2]], investment_per_corop[[2]]) # merging growth and investment data for corop 2
CR02 <- CR02[-c(4:6)] # removing duplicate columns
等等
我的问题是手动重复 COROP 1 到 40 需要很长时间,但我对循环的了解非常有限,我想知道是否有人可以帮助我。是否可以使用循环重复上面的代码来创建从 1 到 40 的新合并数据帧?
谢谢!
【问题讨论】: