I've a table with some numeric and character cols, some are factors and other integers.
>additional.metadata
      sample_id patient_id condition SOM test
1387          1          1       CTL  22    1
7588          1          1       CTL  35    2
7429          1          1       CTL  23    3
7600          1          1       CTL  35    4
I'm trying to convert the entire table to a matrix and, depending of apply option used (i.e. apply vs sapply), some values from $SOM changes. Here's an example:
> apply(additional.metadata, 2, function(x) as.numeric(as.factor(x)))
     sample_id patient_id condition SOM test
[1,]         1          1         1   2    1
[2,]         1          1         1   4    2
[3,]         1          1         1   3    3
[4,]         1          1         1   4    4
[5,]         1          1         1   1    5
[6,]         1          1         1   3    6
> sapply(additional.metadata, function(x) as.numeric(as.factor(x)))
     sample_id patient_id condition SOM test
[1,]         1          1         1  22    1
[2,]         1          1         1  35    2
[3,]         1          1         1  23    3
[4,]         1          1         1  35    4
[5,]         1          1         1  11    5
[6,]         1          1         1  23    6
Someone knows what I'm missing/misunderstanding, please? Thanks in advance.
 
    