I am an R neewbie, so apologies if my question is too basic or if I've violated a forum rule.
I have data in 2-columns. The second column contains the sex (Female-1 and male-2). Column 'a' (first column) contains answer responses to a question which range from (0,1,2,3,4).
How can I get a bar plot of the count of answers, grouped by sex. I am able to do this in excel but I haven't been able to do so in R. In the first instance, I'm unable to transform the data to be usable for plotting. I tried dplyr, etc.
a Sex
1 1
0 2
4 1
2 2
0 1
1 1
2 1
3 1
3 1
2 1
4 2
4 1
2 1
1 2
0 1
2 2
3 1
0 1
4 1
2 1
0 1
1 1
2 2
2 1
1 2
1 2
1 1
0 1
1 1
3
0 1
3 1
4 1
2 2
0 1
1 1
1 2
0 1
3 1
3 1
2 1
1 1
1 1
0 1
0 2
4 1
0 2
0 2
0 2
2 1
2 1
0 2
1 1
4 1
0 1
2 1
0 2
1 2
2 2
0 1
0 1
1 1
1 1
2 2
1 1
0 1
0 2
1 2
0 1
0 1
3 1
0 1
0 2
1 2
0 2
0 1
2
4 2
0 1
1 1
2 2
1 1
4 2
1 1
4 2
0 1
4 2
0 1
2 2
2 1
4 1
2 2
1 1
1 1
2 1
2 1
1 1
3 2
1 1
1 1
2 1
0 2
3 2
2 1
0 1
1 2
2 2
0 2
3 2
2 1
0 1
1 1
1 2
1 1
1 1
0 2
1
0 1
2 1
3 1
0 2
2 1
2 1
0 2
2 1
0 1
0 1
4 1
2 1
2 1
2 1
3 2
2 2
3 1
1 1
2 2
1 1
0 2
2 1
1 2
1 2
0 1
1 2
0 1
2 1
2 1
1 1
2 2
1 1
0 2
2 1
1 1
2 1
2 1
4 2
1 1
0 1
0 1
3 1
3 1
2 1
0 1
1 1
1 1
1 1
2 1
1 1
2 1
2 1
2 1
1 2
2 1
2 1
3 1
0 1
1 2
2 2
1 1
2 1
0 2
0 1
2 1
0 1
0 1
0 1
3 2
2 2
1 2
1 1
1 1
4 1
3 2
2 1
3 1
0 1
1 2
0 1
3
2 2
1 1
3 2
1 2
1 1
2 2
2 2
1 2
0 1
2 2
1 1
2 2
0 2
2 2
0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