I have a vector of character data with repeat values. My ultimate goal is to create a bar plot displaying the frequency at which each unique value occurs in the vector. A long way of doing it would be as follows:
object1=length(df$vector[df$vector=="object1"])
object2=length(df$vector[df$vector=="object2"])
object3=length(df$vector[df$vector=="object3"])
amounts=c(object1,object2, object3)
barplot(amounts)
This works but is cumbersome when there are many unique values, which indicates to me that a loop could be used. I know I can get a vector of the unique values in the original vector via the "unique()" command, but I'm not sure where to go from there. The following posts have made me think, but weren't able to answer my question.
Counting the number of elements with the values of x in a vector