I'm a new bee to the R language and I'm trying to solve a query. I need to simulate rolling a fair coin 200 times and then plot a histogram of the data. So I performed:
outcomes <- c("heads", "tails")
sim_fair_coin <- sample(outcomes, size = 200, replace = TRUE)
hist(table(sim_fair_coin))
This does give me a histogram, but I think I expect a more detailed one. With the X-axis shows "heads" or "tails"; and the Y-axis shows how many times I got for "heads" and "tails". I believe there is a way to accomplish this in R.
Is there any way or code that I can implement to achieve this?