How to draw loess estimation in GGally using ggpairs?

I tried GGally package a little bit. Especially the ggpairs function. However, I cannot figure out how to use loess instead of lm when plot smooth. Any ideas? Here is my code:

require(GGally)
diamonds.samp <- diamonds[sample(1:dim(diamonds)[1],200),]
ggpairs(diamonds.samp[,c(1,5)], 
        lower = list(continuous = "smooth"),
        params = c(method = "loess"),
        axisLabels = "show")

Thanks!

PS compare with the plotmatrix function, ggpairs is much much slower... As a result, most of the time, I just use plotmatrix from ggplot2.


Well the documentation doesn't say, so use the source, Luke

  • You can dig deeper into the source with:

    ls('package:GGally')

    GGally::ggpairs

    ... and browse every function it references ...

    seems like the args get mapped into ggpairsPlots and then -> plotMatrix which then gets called

    So apparently selecting smoother is not explicitly supported, you can only select continuous = "smooth" . If it behaves like ggplot2:geom_smooth it internally automatically figures out which of the supported smoothers to call (loess for <1000 datapoints, gam for >=1000). You might like to step it through the debugger to see what's happening inside your plot. I tried to follow the source but my eyes glaze over.

  • or 2. Browse on https://github.com/ggobi/ggally/blob/master/R/ggpairs.r [4/14/2013]

    #' upper and lower are lists that may contain the variables 'continuous',
    #' 'combo' and 'discrete'. Each element of the list is a string implementing
    #' the following options: continuous = exactly one of ('points', 'smooth',
    #' 'density', 'cor', 'blank') , ...
    #'
    #' diag is a list that may only contain the variables 'continuous' and 'discrete'.
    #' Each element of the diag list is a string implmenting the following options:
    #' continuous = exactly one of ('density', 'bar', 'blank');
    
    链接地址: http://www.djcxy.com/p/30912.html

    上一篇: 如何用GGally :: ggpairs制作气泡图?

    下一篇: 如何使用ggpairs在GGally中绘制黄土估计?