What if the dataset doesn’t have the same variables?
dataset3 <- data.frame(id = rep(letters[1:3], each = 100),
test = c(rpois(100, lambda = 4),
rpois(100, lambda = 5),
rpois(100, lambda = 6)))
# Try to add a new dataset, but it doesn't work because the code for p1 is expecting a "Value" column and that column doesn't exist in dataset3.
p1 %+%
dataset3
Error in `geom_density()`:
! Problem while computing aesthetics.
ℹ Error occurred in the 1st layer.
Caused by error:
! object 'Value' not found
Why doesn’t this work?