## Sample report

This is an example of the type of report you can write in Radiant.

* You can create
* bullet lists

1. And numbered
2. lists

Note: Markdown is used to format the report. Go to [commonmark.org](http://commonmark.org/help/) for an interactive tutorial.

### Math

You can even include math if you want:

$$
\begin{aligned}
  y_t &= \alpha + \beta x_t + \epsilon_{yt}, \\
  z_t &= 3 \times 9 + y_t + \epsilon_{zt}.
\end{aligned}
$$

To show the output press the `Knit report (Rmd)` button.

### Tables

To generate a table that will display properly in both PDF and HTML you can use a layout similar to the example below:

Year  |  Outcome  |  Prior probability
:---- | --------: | :----------------------:
2013  | Win       |  0.30
2014  | Loss      |  0.25
2015  | Win       |  0.20

Note that the columns are left-aligned, right-aligned, and centered using a `:`. Alternatively you can create a `tibble` with the information to be put in the table and use the `kable` function from the `knitr` package to generate the desired output. See example below:

```{r}
tbl <- tibble::tibble(
  Year = c(2013L, 2014L, 2015L),
  Outcome = c("Win", "Loss", "Win"),
  `Prior probability` = c(0.30, 0.25, 0.20)
)

knitr::kable(tbl, align = "ccc")
```

To align the columns use `l` for left, `r` for right, and `c` for center. In the example above each column is centered. For additional information about formatting tables see
https://www.rforge.net/doc/packages/knitr/kable.html

It is also possible to generate interactive tables using the DT package. In Radiant you can use the `dtab` function to display a data.frame as a nicely formatted table:

```{r}
dtab(tbl) %>% render()
```

### Documenting analysis results in Radiant

The report feature in Radiant should be used in conjunction with the <i title='Report results' class='fa fa-edit'></i> icons shown at the bottom of the side bar on (almost) all pages. When that icon is clicked the command used to create the ouput is copied into the editor in the _Report > Rmd_ tab. By default Radiant will paste the code generated for the analysis you just completed at the bottom of the report (i.e., `Auto paste`). However, you can turn off that feature by selecting `Manual paste` from the dropown. With manual paste on, the code is put in the clipboard when you click a report icon and you can paste it where you want in the _Report > Rmd_ editor window.

By clicking the `Knit report (Rmd)` button or pressing CTRL-enter (CMD-enter on Mac), the output from the analysis will be recreated. You can add text, bullets, headers, etc. around the code blocks to describe and explain the results using <a href='http://rmarkdown.rstudio.com/authoring_pandoc_markdown.html' target='_blank'>markdown</a>. You can also select part of the report you want to render.

Below is some code generated by Radiant to produce a scatterplot / heatmap of the price of diamonds versus carats. The colors in the plot reflect the clarity of the diamond.

```{r fig.width = 7, fig.height = 5, dpi = 200}
visualize(
  diamonds,
  xvar = "carat",
  yvar = "price",
  type = "scatter",
  color = "clarity",
  custom = TRUE
) +
  labs(
    title = "Diamond prices",
    x = "Carats",
    y = "Price ($)"
  )
```

> **Put your own code here or delete this sample report and create your own**