1

I have reviewed a number of posts regarding histograms/barcharts from categorical data but I still can't seem to progress. I have a data set of names (single column) and each name occurs anywhere from once to 8,000 times. I can create a table with variable and frequency and I can move that table to a data frame but o matter what I try I can't even get a barplot much less a histogram with variable on x axis and frequency on the y axis.

Ultimately, I want to use the table or dataframe with name and frequency to calculate the Z score for each name and then graph the distribution. I can do this easily with a series of numbers but doing it with a categorical variable has me stumped. thanks, rms

0

1 Answer 1

1

Is this what you're looking for?

example_data <- data.frame(Name = sample(paste0("Name", 1:15), size = 8000, replace=TRUE, prob = (1:15)/sum(1:15)))

counts <- as.data.frame(table(example_data))
colnames(counts) <- c("Name", "Freq")

library(ggplot2)
ggplot(data = counts, aes(x = Name, y = Freq)) + geom_bar(stat="identity")

For future reference, it's a little easier to answer if you provide a reproducible example, or go into more detail about what you've tried already. Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.