This article contains solutions to exercises for an article in the series R for Researchers. For a list of topics covered by this series, see the Introduction. If you're new to R we highly recommend reading the articles in order.

There is often more than one approach to the exercises. Do not be concerned if your approach is different than the solution provided.

Exercise solutions

  1. Open a new R Markdown file with an output format of HTML. Give the document the title "My RFR class notes".

    There is no code associated with the solution to this problem.

    The meta data section of the .Rmd file you opened should be as follows

    ---
    title: "My RFR class notes"
    output: html_document
    ---
  2. Save the file created in exercise 1 as "Notes" in the RFR project folder.

    There is no code associated with the solution to this problem.

  3. Remove all of the document text and commands after the metadata section.

    There is no code associated with the solution to this problem.

  4. Add a level 2 header with the title of this article.

    ## R Markdown
  5. Following the header created in the exercise above, write a note to remind yourself of at least one thing about formatting using Markdown.

    An enumerated list can start with any integer value.
    All additional items in the list are numbered
    sequentially from this starting integer value.
  6. In the text you wrote for the exercise above, use a text modifier (bold, italic, etc.) to highlight a key work or phrase from the text.

    An **enumerated list** can start with ***any integer*** value.
    All additional items in the list are numbered
    ***sequentially*** from this starting integer value.
  7. Ignore the Notes.html file and commit the Notes.Rmd and .gitignore files with the commit message "Added notes for R Markdown article".

    There is no code associated with the solution to this problem.

  8. Demonstrate the use of in line R code to calculate the results of ((43 - 17)*.1)^2.

    The following are a few examples of the use of R code
    
    In line calculation `r ((43 - 17)*.1)^2`
  9. Demonstrate the use of a chunk to calculate the expression from the prior problem.

    A code block
    
    ```{r}
    ((43 - 17)*.1)^2
    ```
  10. Same problem as prior problem with the addition of using chunk option(s) to prevent the R source code from being displayed.

    A code block which does not echo the source text
    
    ```{r echo=FALSE}
    ((43 - 17)*.1)^2
    ```
  11. Commit the Notes.Rmd file with the commit message "Added R code examples to Notes".

    There is no code associated with the solution to this problem.

  • One possible completed Notes.Rmd file

    ---
    title: "My RFR class notes"
    output: html_document
    ---
    
    ## R for Researchers: R Markdown
    
    An **enumerated list** can start with ***any integer*** value.
    All additional items in the list are numbered
    ***sequentially*** from this starting integer value.
    
    The following are a few examples of the use of R code
    
    In line calculation `r ((43 - 17)*.1)^2`
    
    A code block
    
    ```{r}
    ((43 - 17)*.1)^2
    ```
    
    A code block which does not echo the source text
    
    ```{r echo=FALSE}
    ((43 - 17)*.1)^2
    ```

Return to the R Markdown article

Last Revised: 2/2/2015