[R] combn with factors
Greg Hirson
ghirson at ucdavis.edu
Wed Apr 7 19:40:58 CEST 2010
Dear list,
I have come across this issue:
combn(letters[1:5], 3)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] "a" "a" "a" "a" "a" "a" "b" "b" "b" "c"
[2,] "b" "b" "b" "c" "c" "d" "c" "c" "d" "d"
[3,] "c" "d" "e" "d" "e" "e" "d" "e" "e" "e"
combn(factor(letters[1:5]), 3)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] "a" "1" "1" "1" "1" "1" "2" "2" "2" "3"
[2,] "b" "2" "2" "3" "3" "4" "3" "3" "4" "4"
[3,] "c" "4" "5" "4" "5" "5" "4" "5" "5" "5"
I'm not sure why the first combination uses the factor labels and the
remaining combinations use the factor value. In the second case, I
expected that the labels would be used. In any event, I think it could
be consistent - either labels or values.
Is there reason to expect the second case to return the value it did?
This occurs in R 2.10.1
Thanks,
Greg
--
Greg Hirson
ghirson at ucdavis.edu
Graduate Student
Agricultural and Environmental Chemistry
1106 Robert Mondavi Institute North
One Shields Avenue
Davis, CA 95616
More information about the R-help
mailing list