Advice and Considerations
Iterate, iterate, iterate!
And think about
- Titles, captions, axis labels
- Providing context via legends, annotations, background grids and axis ticks, reference lines, labeling
- Text size (readability, relative to figure)
- Telling a story: a series of visualizations presented in an order that builds and reveals
To the Script!
Tables!
Sometimes you just want a table, especially in an interactive report (R Markdown style). Tables are great for
- Looking up or compare individual observations/values
- Including detail and summary values
- Displaying precise values
Options for creating better tables:
- knitr::kable + kableExtra: The
kable()
function, “a very simple table generator,” is defined by the knitr
package. Probably the easiest “pretty” table in R Markdown.
- DT::datatable: The
datatable()
function provides an R interface to the JavaScript library DataTables to produce interactive tables; automatically searchable, sortable.
To the Script!
See the Keye’s post for more on gt
, reactable
and others!
Project organization
A (zipped) folder with
- The original data you’re using (unless it’s downloaded in the script)
- An .R script that reads the original data, performs any cleaning, mutating, filtering, selecting, joining, reshaping, etc. needed for visualization and exports
- An .RDS file (R’s data format) – this will retain all of the changes you’ve made in the cleaning script, including setting or labeling factor levels and geometry/spatial information (things that will be dropped if exported to a .csv file)
- An .Rmd file that reads in the prepared .RDS data, generates the visuals, and contains the narrative (within the .Rmd file, you should be sure to cite your data, and provide a link to it if it is publicly available)
- The knitted .html file created by knitting the .Rmd file
Putting Stuff online
R Markdown can be rendered to formats other than HTML, but HTML files are easy to host online and share! Two possibilities
- RPubs allows free hosting of static single-file R Markdown content – just click the “Publish” button on your html file!
- GitHub Pages, if you’re a GitHub user, allows hosting of Markdown and HTML files from the GitHub repository (that’s how my other class page is hosted)
- A web server like Netlify (Here’s a great webinar on sharing R markdown files, and other sources, on Netlify)
See the chapter in Xie’s R Markdown book for more!