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 elixit 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?
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