ggsmooth               package:ggplot               R Documentation

_G_r_o_b _f_u_n_c_t_i_o_n: _s_m_o_o_t_h

_D_e_s_c_r_i_p_t_i_o_n:

     Add a smooth line to a plot

_U_s_a_g_e:

     ggsmooth(plot = .PLOT, aesthetics=list(), ..., data=plot$data)

_A_r_g_u_m_e_n_t_s:

    plot: the plot object to modify

aesthetics: named list of aesthetic mappings, see details for more
          information

     ...: other options, see details for more information

    data: data source, if not specified the plot default will be used

_D_e_t_a_i_l_s:

     This grob adds a smoother to the graphic to aid the eye in seeing
     important patterns, especially when there is a lot of
     overplotting.

     You can customise this very freely, firstly by choosing the
     function used to fit the smoother (eg. 'loess', 'lm', 'rlm',
     'gam', 'glm') and the formula used to related the y and x values
     (eg. 'y ~ x', 'y ~ poly(x,3)').

     This smoother is automatically restricted to the range of the
     data.  If you want to perform predictions (or fit more complicated
     variabels with covariates) then you should fit the model and plot
     the predicted results.

     Aesthetic mappings that this grob function understands:

        *  x: x position (required)

        *  y: y position (required)

        *  size: size of the point, in mm (see 'scsize)'

        *  colour: point colour (see 'sccolour)'

     These can be specified in the plot defaults (see 'ggplot') or in
     the 'aesthetics' argument.  If you want to modify the position of
     the points or any axis options, you will need to add a position
     scale to the plot.  These functions start with 'ps', eg.
     'pscontinuous' or 'pscategorical'

     Other options:

        *  method: smoothing method (function) to use

        *  formula: formula to use in smoothing function

        *  se: display one standard error on either side of fit? (true
           by default)

        *  other arguments are passed to smoothing function

_A_u_t_h_o_r(_s):

     Hadley Wickham <h.wickham@gmail.com>

_E_x_a_m_p_l_e_s:

     p <- ggpoint(ggplot(mtcars, aesthetics=list(y=wt, x=qsec)))
     ggsmooth(p)
     ggsmooth(p, span=0.9)
     ggsmooth(p, method=lm)
     ggsmooth(p, method=lm, formula = y~splines::ns(x,3))
     ggsmooth(p, method=MASS::rlm, formula = y~splines::ns(x,3))

