[英]merging multiple data frames in R
So I have many data frames and I'm trying to merge them. 所以我有很多数据框,我正在尝试合并它们。 Some of them are in the form:
其中一些格式如下:
sites1 AA1 SA
1 13: C 0.360828
2 14: S 0.017064
3 15: I 0.010810
Others are: 其他是:
sites2 AA2 Freq
1 1: X 0.013
2 1: S 0.987
3 2: L 1.000
I have another data frame linking the proper data frame from the first set with the one from the second set and it goes like this: 我有另一个数据帧,将第一个集合中的正确数据帧与第二个集合中的正确数据帧链接起来,它像这样:
V1 V2
1 1JH6 AT4G18930
2 3MXZ AT2G30410
with the name on the left side corresponding to one data frame and the name on the right side corresponding to another data frame. 左侧的名称对应一个数据框,右侧的名称对应另一数据框。 I'm trying to merge them by doing
我正在尝试通过合并它们
for (i in 1:n){
name = paste("1",names2[i,2])
assign(name,merge(names2[i,1],names2[i,2]))
}
but this just returns a data frame with the two names.. Any help? 但这只会返回带有两个名称的数据框。有什么帮助吗?
try replacing the assign
statement inside your for loop with the following 尝试用以下命令替换for循环内的
assign
语句
assign(name,merge(get(as.character(names2[i,1])),
get(as.character(names2[i,2]))))
Also, consider fixing the name = paste....
statement as follows: 另外,考虑如下修改
name = paste....
语句:
name = paste("T1",names2[i,2], sep="")
# added sep="" to not have a space.
# changed the name so that does not start with a number
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.