1

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.

Freq of Galton Dataset

  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

Dhrub kumar
  • 71
  • 2
  • 7
  • can you provide a minimal code example resembling your data frame? – shayaa Jul 23 '16 at 09:16
  • See [this Q&A on how to include a reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610) – Jaap Jul 23 '16 at 09:59
  • Have you tried `geom_bar(stat="bin")`? – tia_0 Jul 23 '16 at 10:04
  • @shayaa I have edited the question with the code. I guess now you might be able to help me.. – Dhrub kumar Jul 23 '16 at 10:18
  • I would like to but please read the Q&A posted above. I am not able to run your code. It needs to include a small data example which your code can run with. – shayaa Jul 23 '16 at 11:25

0 Answers0