| | ## Data visualizations |
| | |
| | -Data visualizations enrich documents by incorporating statistical analysis and |
| | -plots generated from R code. The application supports R integration for |
| | -creating these elements within R Markdown files. |
| | - |
| | -Follow these steps to run basic R code within the application: |
| | +Data plots can be generated using R. First, create a new file: |
| | |
| | 1. Start the application. |
| | 1. Click **File → New** to create a new file. |
| | 1. Click **File → Save As**. |
| | -1. Set **Name** to: `addition.Rmd` |
| | +1. Set **Name** to: `plot.Rmd` |
| | 1. Click **Save**. |
| | |
| | Setting the file name extension tells the application what processor to use |
| | -when transforming the contents for display in the preview tab. Continue by |
| | -typing in the following text, including the backticks: |
| | - |
| | -``` r |
| | -`r#1 + 1` |
| | -``` |
| | - |
| | -The preview tab shows the result of `1` plus `1`: |
| | - |
| | -> 2.0 |
| | - |
| | -To insert visual content, such as a plot, use ` ```{r}` and ` ``` ` to |
| | -enclose R snippets, such as: |
| | +when transforming the contents. To insert visual content, such as a plot, use |
| | +the knitr-compatible syntax of ` ```{r}` and ` ``` ` to enclose multi-line R |
| | +snippets: |
| | |
| | ```{r} |
| | x <- seq( 0, 2 * pi, length.out=100 ) |
| | y <- sin( x ) |
| | plot( x, y, type="l" ) |
| | ``` |
| | - |
| | -The document shows a plot. |
| | |
| | ## Variable definitions |
 |
| | |
| | 1. Create a new file. |
| | -1. Change the contents to (use spaces not tabs): |
| | +1. Change the contents to (use spaces to indent, not tabs): |
| | |
| | ``` yaml |
 |
| | The preview tab shows: |
| | |
| | -> Project Title |
| | +> 25.0 |
| | |
| | -This is because the application inserts variable reference names based on the type of file being edited. By default, the R engine does not have a function named `x` defined. |
| | +This is because the application inserts variable reference names based on the |
| | +type of file being edited. By default, the R engine does not have a function |
| | +named `x` defined. The `x` function is a fail-safe string conversion function. |
| | |
| | Continue as follows: |
 |
| | This means that the variables can also include expressions that R is capable of |
| | evaluating. |
| | + |
| | +Externally defined variables are assigned to the `v` object in R code. This |
| | +allows dereferencing them using a `$`-separated string. The moustache and |
| | +dot-separated notation also works (e.g., `{{project.title}}`), but better to be |
| | +consistent. |
| | |
| | ## Comma-separated values |
| | |
| | -{{app.title}} ships with many R functions, including one to convert |
| | -comma-separated values into a Markdown table. Consider the following travel |
| | -fares saved as `fares.csv` in the same directory as the main document: |
| | +Many R functions are included, like one that converts comma-separated values to |
| | +tables. Consider travel fares saved as `fares.csv` alongside the main document: |
| | |
| | ``` csv |