title: plotting a Monte Carlo simulation in R
body: <p>I am trying to create a plot that graph a Monte Carlo simulation of a coin toss with iterations on x and probability on y. However, I am having difficulty creating the necessary function.</p>
  
  <p>So far I have</p>
  
  <pre><code>set.seed(2738952)
  coins&lt;-function(n){
      sample(c(0,1),n,replace=TRUE)
  }
  mean(coins(10000)==1)
  
  ggplot(mapping = aes(x=iteration,y=coins))+geom_line()
  </code></pre>
  
  <blockquote>
    <p>Error: Aesthetics must be valid data columns. Problematic aesthetic(s): y = coins. Did you mistype the name of a data column or forget to add stat()?</p>
  </blockquote>
  
  <p>I am unsure how to create the iterations as well as the probability.</p>