Data Viz in R: Week 5
Artwork by @allison_horst
Additional choices to make in your visual representations
Telling a story
While many data and science communicators promote the idea of data as neutral and exhort data visualization to be objective (true?), Klein and D’Ignazio reject this, arguing instead that data visualization should embrace emotion and embodiment.
From Data Feminism: Washington Post Figure
plotly
is a high-level interface to plotly.js, based on d3.js which provides an easier-to-use interface for interactive graphics.
There are two main approaches to initialize a plotly object:
ggplot2
object with ggplotly()
– this converts a ggplot()
object into an interactive plot_ly()
object, but it won’t work for every figure.plot_ly()
directly – this is a different plotting system, so harder to learn, but more customizable.To the Script!
plotly
will automatically include the ability to
See the Sievert book for more!
R Markdown can be rendered to formats other than HTML, but HTML files are easy to host online and share! Two possibilities
See the chapter in Xie’s R Markdown book for more!
Sometimes you just want a table, especially in an interactive report (R Markdown style). Tables are great for
Options for creating better tables:
kable()
function, “a very simple table generator,” is defined by the knitr
package. Probably the easiest “pretty” table in R Markdown.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!
XKCD, Randall Munroe, https://xkcd.com/1301/