[R] Count data with several numbers separated by commas
Xiyan Lon
xiyanlon at gmail.com
Thu Apr 16 08:03:39 CEST 2009
Dear all,
I have a data file with 3 variables (x1, x2, x3) where variable x1
have data that consists of several numbers separated by commas.
id name x1 x2 x3
aa101 1,4,5 2 1
aa102 1,2,5 1 2
aa103 1,2,5 1 1
aa104 1,2,3 1 2
aa105 1,5 2 2
aa106 1,2,5 2 2
aa107 1,2,5 2 1
aa108 1,4,5 2 1
aa109 1,2 1 2
aa110 3,5 1 2
I want to count the number of data for each variables and make barplot
for each variables.
I know how to count for variable x2 and x3 and make barplot for x2 and
x3, but I don't know how to count data in variable x1.
Are there any trick how to count data in variable x1?
The result maybe like:
x1
1 9
2 6
3 2
4 4
5 8
x2
1 5
2 5
x3
1 4
2 6
Thank you for any help.
Xiyanlon
More information about the R-help
mailing list