r - combn unclasses factor variables -


update: fixed

this fixed in upcoming release of r 3.1.0. changelog:

combn(x, simplify = true) gives factor result factor input x (previously user error).
related pr#15442


i noticed curious thing. why combn appear unclass factor variables underlying numeric values except first combination?

x <- as.factor( letters[1:3] )  combn( x , 2 ) #     [,1] [,2] [,3] #[1,] "a"  "1"  "2"  #[2,] "b"  "3"  "3"  

this doesn't occur when x character:

x <- as.character( letters[1:3] )  combn( x , 2 ) #     [,1] [,2] [,3] #[1,] "a"  "a"  "b"  #[2,] "b"  "c"  "c" 

reproducible on r64 on os x 10.7.5 , windows 7.

i think due conversion matrix done simplify parameter. if don't use get:

combn( x , 2 , simplify=false) [[1]] [1] b levels: b c  [[2]] [1] c levels: b c  [[3]] [1] b c levels: b c 

the fact first column ok due way combn works: first column specified separately , other columns changed existing matrix using [<-. consider:

m <- matrix(x,3,3) m[,2] <- sample(x) m      [,1] [,2] [,3] [1,] "a"  "1"  "a"  [2,] "b"  "3"  "b"  [3,] "c"  "2"  "c"  

i think offending function therefore [<-.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -