Creating Basic Plots with ggplot2
Instruction: Demonstrate how to create a basic scatter plot using ggplot2 with a dataset containing 'height' and 'weight' columns.
Context: This question tests the candidate's ability to use ggplot2 for basic data visualization tasks. It evaluates the candidate's familiarity with one of the most popular visualization packages in R, essential for data analysis and insights presentation.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Map the two numeric columns in aes, then add geom_point. State the units rather than assuming them from column names.
library(ggplot2) health_data <- data.frame(height = c(160, 170, 180), weight = c(55, 70, 85)) p <- ggplot(health_data, aes(x = height, y = weight)) + geom_point(size = 2) + labs(title =...