Displaying 2 results from an estimated 2 matches for "data2a".
Did you mean:
data2
2010 May 28
1
Match 2 vectors
...dataframes of unequal length, and I would like to match a
factor to them so that both dataframes will have the same number of
rows.
example:
# create the 2 dataframes with unequal length
data1 <- data.frame(letters, 1:26)[-c(5,10,19:21),]
data2 <- data.frame(letters, 1:26)[-c(6,9,15:18),]
data2a <- match(data1[,1], data2[,1])
data2b <- data2[data2a,]
When I match data1 to data2, and combine the data2a vector to the
original data2, I'm still missing some rows. I need to get the 26
rows, and preferably with the first column displaying all the levels.
In data2b the mismatches show...
2005 Nov 29
1
Indexing variables within lapply?
...data1b :`data.frame': 77 obs. of 63 variables:
.. ..$ var1 : num [1:77] 1284.59 7.59 1.16 8.66 2646.38 ...
.. ..$ var2 : num [1:77] 1.231 1.129 0.427 1.132 0.692 ...
.. ..$ var3 : num [1:77] 1.36 0.68 1.39 2.54 1.39 ...
.
.
.
$ data2:List of 2
..$ data2a :`data.frame': 77 obs. of 63 variables:
.. ..$ var1 : num [1:77] 0.41375 0.00056 1.43040 1.43528 0.61730 ...
.. ..$ var2 : num [1:77] 1.154 1.686 0.673 0.800 0.760 ...
.. ..$ var3 : num [1:77] 1.245 0.575 0.934 0.461 0.757 ...
.
.
.
..$ data2b :`data...