vignettes/pkgdown/report_rmd.Rmd
report_rmd.Rmd
Create a (reproducible) report using Rmarkdown
The best way to store your work in Radiant is to use the Report > Rmd feature and save a state file with all your results and settings. The report feature in Radiant should be used in conjunction with the icons shown on the bottom left of your screen on most pages.
The editor shown on the left in Report > Rmd shows past commands in R-code chunks. These chunks can include R-code you typed or R-code generated by Radiant and added to the report after clicking an icon. All code chunks start with ```{r}
and are closed by ```
By default Radiant will add the R-code generated for the analysis you just completed to the bottom of the report. After clicking a icon Radiant will, by default, switch to the Report > Rmd tab. Click inside the editor window on the left and scroll down to see the generated commands.
If you want more control over where the R-code generated by Radiant is put into your report, choose Manual paste
instead or Auto paste
from the appropriate drop-down in the Report > Rmd tab. When Manual paste
is selected, the code is put into the clipboard when you click and you can paste it where you want in the editor window.
If you started Radiant from Rstudio, you can also choose to have commands sent to an Rmarkdown (R-code) document open in Rstudio by selecting To Rmd
(To R
) instead of Auto paste
or Manual paste
. If you choose To Rmd
the editor in Report > Rmd will be hidden (i.e., “Preview only”) and clicking on Knit report (Rmd)
will source the text and code directly from Rstudio.
By default, the app will switch to the Report > Rmd tab after you click the icon. However, if you don’t want to switch tabs after clicking a icon, choose Don't switch tab
from the appropriate drop-down in the Report > Rmd tab. Don't switch tab
is the default option when you choose To Rmd
.
You can add text or additional commands to create an Rmarkdown document. An Rmarkdown file (extension .Rmd) is a plain text file that can be opened in Notepad (Windows), TextEdit (Mac), Rstudio, Sublime Text, or any other text editor. Please do not use Word to edit Rmarkdown files.
Using Rmarkdown is extremely powerful because you can replicate your entire analysis quickly without having to generate all the required R-code again. By clicking the Knit report (Rmd)
button on the top-left of your screen, the output from the analysis will be (re)created and shown on the right of the Report > Rmd page. To evaluate only a part of the report use the cursor to select a section and press CTRL-enter
(CMD-enter
on mac) to create the (partial) output.
You can add text, bullets, headers, etc. around the code chunks to describe and explain the results using markdown. For an interactive markdown tutorial visit commonmark.org.
If you started Radiant from Rstudio you can save the report in various formats (i.e., Notebook, HTML, Word, Powerpoint, or PDF). For more on generating powerpoint presentation see https://bookdown.org/yihui/rmarkdown/powerpoint-presentation.html. To save the Rmarkdown file open in the editor select Rmd
(or Rmd + Data (zip)
) and press Save report
. Previously saved Rmarkdown files can be loaded into Radiant by using the Load report
button. For more
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. You can also read images, R-code, and text (e.g., Rmd or md) to include in your report. If the file type you want to load is not currently supported, the path to the file will be returned. If Radiant was started from an Rstudio project, the file paths used will be relative to the project root. Paths to files synced to local Dropbox or Google Drive folder will use the find_dropbox
and find_gdrive
functions to enhances reproducibility.
The best way to save your analyses and settings is to save the state
of the application to a file by clicking on the icon in the navbar and then clicking on Save radiant state file
. The state file (extension rda) will contain (1) the data loaded in Radiant, (2) settings for the analyses you were working on, (3) and any reports or code from the Report > Rmd and Report > R. Save the state file to your hard-disk and, when you are ready to continue, simply load it by icon in the navbar and then clicking on Load radiant state file
If you are using Radiant for a class I suggest you use the Report > Rmd feature to complete assignments and cases. When you are done, generate an (HTML) Notebook (or Word or PDF) report by clicking the Save report
button. Submit both the report and your state file.
The editor used in Report > Rmd and Report > R has several options that can be set in .Rprofile
. You can use usethis::edit_r_profile()
to alter the settings 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") options(radiant.powerpoint_style = "~/Dropbox/rmd-styles/style.potx") options(radiant.word_style = "~/Dropbox/rmd-styles/style.docx")
Notes:
vim.keys
enables a set of special keyboard short-cuts. If you have never used VIM you probably don’t want thisshinyAce::getAceThemes()
showInvisibles
shows tabs and spaces in the editoroptions
as shown above to tell Radiant where to find the style files you want to use.
For an overview of related R-functions used by Radiant to generate reproducible reports see Report