Your count matrix might have quotation marks in it, values might be getting imported as strings and converted to factors:

> x <- data.frame(A=factor(c(0,0,0,0,1,3,3,4)), B=factor(c(0,1,0,1,2,3,4,5)))
> x <- data.frame(A=factor(c(0,0,0,0,1,3,3,4)), B=factor(c(0,1,0,1,2,3,4,5)))
> print(x)
  A B
1 0 0
2 0 1
3 0 0
4 0 1
5 1 2
6 3 3
7 3 4
8 4 5
> as.matrix(x)        
     A   B  
[1,] "0" "0"
[2,] "0" "1"
[3,] "0" "0"
[4,] "0" "1"
[5,] "1" "2"
[6,] "3" "3"
[7,] "3" "4"
[8,] "4" "5"

Check your data file for quotation marks around the numbers. It could be something to do with how the file is being imported. Try "read.table" and specify the quoting character (quote=""") .



Source link