Suppose I have the following dataset
set.seed(85)
a <- data.frame(replicate(10,sample(0:3,5,rep=TRUE)))
and I plot it in the following way:
library(ggplot2)
ggplot(stack(a), aes(x = values)) +
geom_bar()
From the graph I can read that there are a little less than 1250 occurrences of '3' in the dataset, but is there a way to output frequency of each x-axis value in the dataset as an independent list (i.e. not as numbers on the barplot)? I am looking for a list of how many occurrences of '3' there are in the dataset (and also for the values, 0, 1, & 2).
output:
0: 1249
1: 1200
2: ...
3: ...
Any help is much appreciated