[R] Correcting for missing data combinations

2009-12-11 Thread GL
I can think of many brute-force ways to do this outside of R, but was wondering if there was a simple/elegant solution within R instead. I have a table that looks something like the following: Factor1 Factor2 Value A 11/11/2009 5 A 11/12/2009 4 B 11/11/2009

Re: [R] Correcting for missing data combinations

2009-12-11 Thread Charles C. Berry
On Fri, 11 Dec 2009, GL wrote: I can think of many brute-force ways to do this outside of R, but was wondering if there was a simple/elegant solution within R instead. I have a table that looks something like the following: Factor1 Factor2 Value A 11/11/2009 5 A

Re: [R] Correcting for missing data combinations

2009-12-11 Thread Greg Hirson
One approach would be to use expand.grid to generate all combinations and then match against what you have. A short example: #generate data - two factors - 4 levels in factor1, 26 levels in factor2 df - data.frame(factor1 = sample(LETTERS[1:4], 100, replace=T), factor2 = sample(letters,

Re: [R] Correcting for missing data combinations

2009-12-11 Thread Gray Calhoun
This is nice; the matching could be shortened by using merge: ### quoted from the previous message #generate data - two factors - 4 levels in factor1, 26 levels in factor2 df - data.frame(factor1 = sample(LETTERS[1:4], 100, replace=T), factor2 = sample(letters, 100, replace=T), value =