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
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
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,
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 =
4 matches
Mail list logo