How do I create a histogram in R with x coordinates having nonnumeric labels and frequency totals shown
histogram, r, usage-statistics
Solution
You mean a barchart?
> barplot(height=table(draws))
Problem
I am creating a simulated dataset and I want to create a histogram based on x values that are not numeric. Here is what I have: ``` x <- c("CF", "CH", "CJ", "CE", "CN", "EC", "EN", "EJ", "AB", "BA", "KO", "OD", "DL", "HG") px = c(0.08, 0.10, 0.06, 0.20, 0.04, 0.15, 0.02, 0.10, 0.025, 0.025, 0.05, 0.05, 0.05, 0.05) draws = sample(x, size = 1000, replace = TRUE, prob = px) hist( draws) ``` I would like the histogram to have the values for x as labels and also each of the bars to show the total frequency that each value of x was sampled. Any help would be appreciated!!