Using RMarkdown

Text

Text can be decorated with bold or italics. It is also possible to

  • create links
  • include mathematics like \(e=mc^2\) or \[y = \beta_0 + \beta_1 x_1 + \beta_2 x_2\]

Be sure to put a space after the * when you are creating bullets and a space after # when creating section headers, but not between $ and the mathematical formulas.

Graphics

If the code of an R chunk produces a plot, this plot can be displayed in the resulting file.

Rail Trail Usage Volume

ggplot(data=RailTrail,aes(x=avgtemp,y=volume))+geom_point()+aes(colour=weekday)+aes(size=precip) 

R output

Other forms of R output are also displayed as they are produced.

favstats(~ volume, data=RailTrail)
##  min    Q1 median     Q3 max  mean       sd  n missing
##  129 291.5    373 451.25 736 375.4 127.4626 90       0

Destination formats

This file can be knit to HTML, PDF, or Word. In RStudio, just select the desired output file type and click on Knit HTML, Knit PDF, or Knit Word. Use the dropdown menu next to that to change the desired file type.

Documenting file creation

It’s useful to record some information about how your file was created.

  • File creation date: 2015-05-27
  • R version 3.2.0 (2015-04-16)
  • R version (short form): 3.2.0
  • mosaic package version: 0.10.9000
  • Additional session information
## R version 3.2.0 (2015-04-16)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 7 x64 (build 7601) Service Pack 1
## 
## locale:
## [1] LC_COLLATE=English_United States.1252 
## [2] LC_CTYPE=English_United States.1252   
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.1252    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] knitr_1.10.5     mosaic_0.10.9000 mosaicData_0.9.1 ggplot2_1.0.1   
## [5] lattice_0.20-31  dplyr_0.4.1      car_2.0-25      
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_0.11.6      nloptr_1.0.4     plyr_1.8.2       tools_3.2.0     
##  [5] digest_0.6.8     lme4_1.1-7       evaluate_0.7     nlme_3.1-120    
##  [9] gtable_0.1.2     mgcv_1.8-6       Matrix_1.2-0     DBI_0.3.1       
## [13] yaml_2.1.13      parallel_3.2.0   SparseM_1.6      proto_0.3-10    
## [17] ggdendro_0.1-15  gridExtra_0.9.1  stringr_1.0.0    grid_3.2.0      
## [21] nnet_7.3-9       rmarkdown_0.6.1  minqa_1.2.4      reshape2_1.4.1  
## [25] magrittr_1.5     scales_0.2.4     htmltools_0.2.6  MASS_7.3-40     
## [29] splines_3.2.0    assertthat_0.1   pbkrtest_0.4-2   colorspace_1.2-6
## [33] labeling_0.3     quantreg_5.11    stringi_0.4-1    munsell_0.4.2