Difference between revisions of "SMHS Usage Rfundamentals"
(Created page with "==SMHS_Usage: SMHS EBook Usage - Some R Fundamentals== ===Command-line Help=== > apropos("nova") # within R keyword search/help ===Saving R commands/scripts and HTML o...") |
(No difference)
|
Revision as of 07:44, 12 April 2016
Contents
SMHS_Usage: SMHS EBook Usage - Some R Fundamentals
Command-line Help
> apropos("nova") # within R keyword search/help
Saving R commands/scripts and HTML outputs
It's easy to save R scripts and commands that can be reused, shared and modified later or by others, as well as to create HTML or PDF files with R, Knitr, MiKTeX.
Needed packages
You may need to first install Knitr and Markdown (and/or MiKTeX/Pandoc). Open R or RStudio and install the packages:
# Install knitr install.packages("knitr") install.packages("markdown")
Create a .Rmd File Containing Your Complete Protocol
Open RStudio, click File --> New --> R Markdown, and enter meta-data (e.g., Author). Save as example.Rmd -- this generates an R Markdown document. A new markdown (.Rmd) file will be created that is populated with an example and contains the both R code and knitr code. Code between the sets of three apostrophes ```{r}
and ```
is pure R code. Code outside of these segments is knitr code (necessary for the export of entire protocol to HTML/PDF/etc). The R code tells R what to do and the Knitr code creates the output doc (e.g., HTML file). Below is an example of a fresh new Rmd file that is automatically generated as an example:
--- title: "SOCR Demo" author: "SOCR Team" date: "April 12, 2016" output: html_document --- 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: ```{r} summary(cars) ``` You can also embed plots, for example: ```{r, echo=FALSE} plot(cars) ``` Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
- SOCR Home page: http://www.socr.umich.edu
Translate this page: