create a bar graph by counting the elements in an array in r in r

# Create an array
array <- c("apple", "banana", "apple", "orange", "banana", "apple")

# Count the frequency of each element in the array
counts <- table(array)

# Create a bar graph
barplot(counts, main="Frequency of Elements in Array", xlab="Elements", ylab="Frequency")
273 chars
9 lines

gistlibby LogSnag