Data Viz in R: Week 2
Is it Truthful? Does it get the information as right as possible? Are you honest with yourself and your audience?
Is it Functional? does it help your audience interpret the information correctly? Has the purpose in producing the figure shaped the information?
Is it Beautiful? Does it elicit an emotional experience for the reader – awe, wonder, pleasure, surprise? If appropriate, is it simple and elegant?
Is it Insightful? Does it reveal new knowledge, either spontaneously or gradually? Does it reveal something to the reader, helping them build knowledge?
Is it Englightening? Does it provoke a reader to change their mind? Does it contribute to improving well being?
Considering equity: Are we using language and images that are inclusive? When do we need to provide historical and social context for problems people are facing? How might our work might be misunderstood? When should we collaborate to bridge substantive and visual?
Reject the idea that data is neutral, that data visualization can be objective (true?); instead that data visualization should embrace emotion and embodiment.
Next week: your examples of bad data viz!
Factors are variables which take on a limited number of values, aka categorical variables. In R, factors are stored as a vector of integer values with the corresponding set of character values you’ll see when displayed (colloquially, labels; in R, levels).
property %>% count(condition) # currently a character
property %>%
mutate(condition = factor(condition)) %>% # make a factor
count(condition)
# assert the ordering of the factor levels
cond_levels <- c("Excellent", "Good", "Average", "Fair", "Poor", "Very Poor", "Unknown")
property %>%
mutate(condition = factor(condition, levels = cond_levels)) %>%
count(condition)
The forcats
package, part of the tidyverse
, provides helper functions for working with factors. Including
ggplot
breaks up the task of making a graph into a series of distinct tasks (layering); each task is carried out in code based on identifiable functions (geom_, scale_, labs, legends, and more).