Re: [R] merging data frames with matrix objects when missing cases

2009-09-18 Thread Kari Ruohonen
Yes, that was the original question: when a variable in a data frame is a matrix instead of an ordinary variable merge() handles the missing cases so that only the first column of the matrix gets NA and the rest are recycled. If the matrix is broken to several variables everything works fine. Why

Re: [R] merging data frames with matrix objects when missing cases

2009-09-18 Thread johannes rara
This has something to do with your data.frame structure see > str(df1) 'data.frame': 3 obs. of 2 variables: $ a : int 1 2 3 $ X1: 'AsIs' int [1:3, 1:2] 1 2 3 4 5 6 > str(df2) 'data.frame': 2 obs. of 2 variables: $ a : int 1 2 $ X2: 'AsIs' int [1:2, 1:2] 11 12 13 14 This seems to work

[R] merging data frames with matrix objects when missing cases

2009-09-18 Thread Kari Ruohonen
Hi, I have faced a problem with the merge() function when trying to merge two data frames that have a common index but the second one does not have cases for all indexes in the first one. With usual variables R fills in the missing cases with NA if all=T is requested. But if the variable is a matri