How would I do a bar plot of the frequency of non-numerical data using R?
e.g. if given v = c("B","A","B","A","B","D","C","D","D","D","C")
I want to get a bar plot in which each bar represents a unique value from the vector and the height of each bar to correspond with the frequency of that value:
Calculate the table of values for the barplot using the table()
function, e.g.:
v <- c("B","A","B","A","B","D","C","D","D","D","C")
barplot(table(v))
This produces
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With