I have a table which I would like to convert into matrix of rows and columns:
x=read.table("file")
10716052 AF004884 2 AutonomicNervousDisorders
10716052 AF004884 11 CardiovascularDisorders
10716052 AF004884 9 GastrointestinalDisorders
10716052 AF004884 2 Hemorrhage
10716052 AF004884 1 MetabolicandNutritionalDisorders
10716052 AF004884 2 Musculo-skeletalSystem
10716052 AF004884 5 NervousSystem
10716052 AF004884 4 OphthalmicDisorders
10716052 AF004884 7 PathologicalDisorders
10716052 AF004884 5 PulmonaryDisorders
10716052 AF004884 2 RespiratorySystem
10716052 AF004884 3 SkinandAppendages
10716052 AJ251368 2 AutonomicNervousDisorders
10716052 AJ251368 11 CardiovascularDisorders
10716052 AJ251368 9 GastrointestinalDisorders
10716052 AJ251368 2 Hemorrhage
10716052 AJ251368 1 MetabolicandNutritionalDisorders
I am following this post which says to use "library reshape" in R.
library(reshape)
cast(x, V1 ~ V2)
But I am getting the additive results:
V1 AF004884 AJ251368 AJ272268 L35901 M65212
1 10716052 12 12 12 12 1
I would like to have each instance of the column names with their respective counts as they belong to different categories.