Summarizing and Visualizing Data in R
From a Tidy Table to an Honest Summary and Plot
A tidy data table has one observation per row, one variable per column, and one value per cell. Before summarizing, inspect variable types, units, grouping categories, duplicates, and missing values. A mean answers a different question from a median; a count answers a different question from a proportion.
With dplyr, group_by() declares groups and summarise() reduces each group to named statistics. State what happens to missing values: mean(x, na.rm=TRUE) excludes missing x values, whereas the default may return missing. The denominator for a proportion should be visible, especially if data are missing.
In ggplot2, ggplot(data, aes(x=..., y=...)) maps variables to aesthetics, then a geom chooses marks: points for paired observations, bars for counts or supplied summaries, and lines for ordered trajectories.
Labels need units and an informative title. A visually separated group difference is descriptive evidence; it does not establish a causal mechanism without a design that supports one.
A dataset has one row per plant with numeric height and numeric leaf area. Which ggplot2 geometry most directly displays their pairwise relationship?
A numeric vector contains 8, 10, and one missing value. What does mean(x, na.rm = TRUE) compute?