search for: myjoincolumn

Displaying 1 result from an estimated 1 matches for "myjoincolumn".

Did you mean: myjoincolumns
2011 Aug 10
2
join columns
...m the following, and I know it may not that quite welly written, but it works. Any suggestions are welcome, many thanks. Anthony > q1 = data.frame(a=1,b=2,c=3,row.names="q1") a b c q1 1 2 3 > q2 = data.frame(d=4,b=1,a=4, row.names="q2") d b a q2 4 1 4 -> myJoinColumns(q1,q2) a b c d q1 1 2 3 0 q2 4 1 0 4 myJoinColumns <- function(q1,q2){ allNames = sort(union(colnames(q1),colnames(q2))) for (i in 1:length(allNames)){ t1 = which(colnames(q1) == allNames[i]) t2 = which(colnames(q2) == allNames[i]) if (length(t1) == 1){ sec1 = q1[,...