For plotting, I generally use table
function in Base package which automatically takes care of count and I use in geom_point
aesthetics (size = freq
). Is there any alternate to this. Every time I have to individually convert them to table(x, y)
just to inset count column.
y <- galton$child - mean(galton$child)
x <- galton$parent - mean(galton$parent)
***freqData <- as.data.frame(table(x, y))***
names(freqData) <- c("child", "parent", "freq")
freqData$child <- as.numeric(as.character(freqData$child))
freqData$parent <- as.numeric(as.character(freqData$parent))
myPlot <- function(beta){
g <- ggplot(filter(freqData, freq > 0), aes(x = parent, y = child))
g <- g + scale_size(range = c(2, 20), guide = "none" )
g <- g + geom_point(colour="grey50", aes(size = freq+20, show_guide = FALSE))
}
My Question is Is there any alternate function doing the task what table(x,y) is doing