8.6 Exploring pairwise relationships between predictors
Plot a scatterplot with diameter’ vs ‘mass’ with ‘flat’ indicator (fig. 8.2)
<-
scat_flat %>%
scat mutate(flat = ifelse(flat == 1, "yes", "no"))
%>%
scat_flat ggplot(aes(col = flat)) +
geom_point(aes(x = Diameter, y = Mass), alpha = .5) +
geom_rug(data = scat_flat[is.na(scat_flat$Mass),],
aes(x = Diameter),
sides = "b",
lwd = 1)+
geom_rug(data = scat_flat[is.na(scat_flat$Diameter),],
aes(y = Mass),
sides = "l",
lwd = 1) +
theme(legend.position = "top")
## Warning: Removed 7 rows containing missing values (`geom_point()`).
<- scat %>%
scat_flat_NA mutate(diameter_NA = are_na(Diameter) %>% as.numeric())
cor(scat_flat_NA$flat, scat_flat_NA$diameter_NA)
## [1] 1