I have a roulette wheel simulation that plots a frequency versus roulette wheel slot (or factor) but I would also like to view % relative frequency vs. factor.
black_on_wheel = paste("B", 1:18, sep = "")
red_on_wheel = paste("R", 1:18, sep = "")
roulette_wheel = c(red_on_wheel, black_on_wheel, "0", "00")
simulated_roulette_wheel = sample(roulette_wheel, size=500, replace = TRUE)
plot(rw_runs)
As @joran pointed out, you can use
tableandprop.table:In
barplot,xaxs="i"allows the bars to start at the origin in x coordinate and the functionbox()adds a box to the plot.The first ten elements of
prop.tablooks like:If you don’t multiply
prop.table(tab)by 100, then you will only obtain a proportion instead of relative percentage.Here’s the barplot generated: