Create a (reproducible) report using R

The Report > R tab allows you to run R-code with access to all functions and data in Radiant. By clicking the Knit report (R) button, the code will be evaluated and the output will be shown on the right of the Report > R page. To evaluate only a part of the code use the cursor to select a section and press CTRL-enter (CMD-enter on mac).

You can load an R-code file into Radiant by clicking the Load report button and selecting an .r or .R file. If you started Radiant from Rstudio you can save a report in HTML, Word, or PDF format by selecting the desired format from the drop-down menu and clicking Save report. To save just the code choose R from the dropdown and press the Save report button.

If you started Radiant from Rstudio, you can also click the Read files button to browse for files and generate code to read it into Radiant. For example, read rda, rds, xls, yaml, and feather and add them to the Datasets dropdown. If the file type you want to load is not currently supported, the path to the file will be returned. The file path used will be relative to the Rstudio-project root. Paths to files synced to a local Dropbox or Google Drive folder will use the find_dropbox and find_gdrive functions to enhances reproducibility.

As an example you can copy-and-paste the code below into the editor and press Knit report (R) to generate results.

## get the active dataset and show the first few observations
.get_data() %>%

## access a dataset
diamonds %>%
  select(price, clarity) %>%

## add a variable to the diamonds data
diamonds <- mutate(diamonds, log_price = log(price))

## show the first observations in the price and log_price columns
diamonds %>%
  select(price, log_price) %>%

## create a histogram of prices
diamonds %>%
  ggplot(aes(x = price)) +

## and a histogram of log-prices using
visualize(diamonds, xvar = \"log_price\", custom = TRUE)

## open help in the R-studio viewer from Radiant
help(package = \"\")

## If you are familiar with Shiny you can call reactives when the code
## is evaluated inside a Shiny app. For example, if you transformed
## some variables in Data > Transform you can call the transform_main
## reacive to see the latest result. Very useful for debugging
# transform_main() %>% head()


The editor used in Report > Rmd and Report > R has several options that can be set in .Rprofile.

options(radiant.ace_vim.keys = FALSE)
options(radiant.ace_theme = "cobalt")
options(radiant.ace_tabSize = 2)
options(radiant.ace_useSoftTabs = TRUE)
options(radiant.ace_showInvisibles = TRUE)
options(radiant.ace_autoComplete = "live")



For an overview of related R-functions used by Radiant to generate reproducible reports see Report

© Vincent Nijs (2018) Creative Commons License