I would like to concatenate multiple vectors into a data frame, using the names of each vector to guide the concatenation.
for instance if I have vectors x1, x2, and x3:
sample(1:50,20)->x1; sample(1:50,20)->x2; sample(1:50,20)->x3
and each vector has names such:
nam <- paste("A",1:50, sep=""); names(x1)<-as.character(sample(nam,20)); names(x2)<-as.character(sample(nam,20)); names(x3)<-as.character(sample(nam,20))
I would like to generate a data frame in which the first column contains all names used in at least one vector and the rest of the columns containing the values associated to each vector with "na" when there is no value for a particular name. Something like this:
A1 3 NA NA
A2 NA 4 5
A3 NA 3 NA
A4 NA 22 NA
....
That would mean that the name A1 is associated with a value (which is 3) only in x1, but not in x2 or x3. A2 is associated with value only in vector x2 and x3 but not in x1. Etc.
Any idea of how to do this?
Thank you very much,