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!!
You mean a barchart?
> barplot(height=table(draws))
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