Reputation: 31
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?
Upvotes: 2
Views: 658
Reputation: 55340
try replacing the assign
statement inside your for loop with the following
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("T1",names2[i,2], sep="")
# added sep="" to not have a space.
# changed the name so that does not start with a number
Upvotes: 1