I read in this forum a lot of posts about converting the columns of my data.frame from character to numeric, but I did not succeed in solving my problem..
So..
My data.frame is loaded from my personal folder using
a <- read.table("pe.txt", header=T, sep="", dec=",")
the numbers in the pe.txt table have the "," to separate the decimal numbers. the output "a" is:
PHYLA Ti_01 T2_01 T4_01 Ti_02
1 Acidobacteria 0.000 0.000 0.000 0.000
2 Actinobacteria 0.506 0.055 0.187 0.261
3 Archaea - Euryarchaeota 0.000 0.000 0.000 0.000
4 Bacteroidetes 48.902 57.823 28.495 53.450
5 Cyanobacteria 0.011 0.011 0.712 0.000
Afterwards, I deleted the column "PHYLA" putting it as "colnames".
Results:
Ti_01 T2_01 T4_01 Ti_02
Acidobacteria 0.000 0.000 0.000 0.000
Actinobacteria 0.506 0.055 0.187 0.261
Archaea - Euryarchaeota 0.000 0.000 0.000 0.000
Bacteroidetes 48.902 57.823 28.495 53.450
Cyanobacteria 0.011 0.011 0.712 0.000
Now, all the table is formed by number. so, I tried to use the code to transform all in numeric. No way! I use the code below to understand if the factors are numeric or character and this is the result:
sapply(a,mode)
PHYLA Ti_01 T2_01 T4_01 Ti_02
"numeric" "numeric" "numeric" "numeric" "numeric"
My goal at the end is to sum the rows between them...
apply(a,2,sum)
Errore in FUN(newX[, i], ...) : invalid 'type' (character) of argument
rowSums(a)
Errore in rowSums(a) : 'x' deve essere di tipo numeric
In my opinion the error is during "read.table". Until that point the R output smells bad for me...