This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
num_darts <- 9999
num_darts_in_circle <- 0
x <- runif(n=num_darts, min=-1, max=1)
y <- runif(n=num_darts, min=-1, max=1)
sum_sqr <- x^2 + y^2
indexes_darts_in_circle <- which(sum_sqr<=1)
num_darts_in_cir <- length(indexes_darts_in_circle)
print(4*num_darts_in_cir/num_darts)
## [1] 3.135114
sprintf("%.15f",4*num_darts_in_cir/num_darts)
## [1] "3.135113511351135"
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.