Last active
August 29, 2015 14:05
-
-
Save jeffreyiacono/75beda74a4370dd81b53 to your computer and use it in GitHub Desktop.
Galton Child vs Parent height freq-sized scattersplot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(UsingR) | |
library(ggplot2) | |
library(reshape) | |
data(galton) | |
freqData <- as.data.frame(table(galton$child, galton$parent)) | |
names(freqData) <- c("child", "parent", "freq") | |
freqData$child <- as.numeric(as.character(freqData$child)) | |
freqData$parent <- as.numeric(as.character(freqData$parent)) | |
g <- ggplot(freqData[freqData$freq > 0, ], aes(x = parent, y = child)) | |
g <- g + scale_size(range = c(2, 20), guide = "none") | |
g <- g + geom_point(color = "grey50", aes(size = freq, show_guide = FALSE)) | |
g <- g + geom_point(aes(color = freq, size = freq)) | |
g <- g + scale_color_gradient(low = "lightblue", high = "white") | |
g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment