I am trying to replicate this simple example given in the Coursera R Regression Models course:
require(datasets)
data(swiss)
require(GGally)
require(ggplot2)
ggpairs(swiss, lower = list(continuous = "smooth", params = c(method = "loess")))
I expect to see a 6x6 pairs plot - one scatterplot with loess smoother and confidence intervals for each combination of the 6 variables in the swiss data.
However, I get the following error:
Error in display_param_error() : 'params' is a deprecated argument. Please 'wrap' the function to supply arguments. help("wrap", package = "GGally")
I looked through the ggpairs()
and wrap()
help files and have tried lots of permutations of the wrap()
and wrap_fn_with_param_arg()
functions.
I can get this to work as expected:
ggpairs(swiss, lower = list(continuous = wrap("smooth")))
But once I add the loess part in, it does not:
ggpairs(swiss, lower = list(continuous = wrap("smooth"), method = wrap("loess")))
I get this error when I tried the line above.
Error in value[3L] : The following ggpair plot functions are readily available: continuous: c('points', 'smooth', 'density', 'cor', 'blank') combo: c('box', 'dot', 'facethist', 'facetdensity', 'denstrip', 'blank') discrete: c('ratio', 'facetbar', 'blank') na: c('na', 'blank')
diag continuous: c('densityDiag', 'barDiag', 'blankDiag') diag discrete: c('barDiag', 'blankDiag') diag na: c('naDiag', 'blankDiag')
You may also provide your own function that follows the api of function(data, mapping, ...){ . . . } and returns a ggplot2 plot object Ex: my_fn <- function(data, mapping, ...){ p <- ggplot(data = data, mapping = mapping) + geom_point(...) p } ggpairs(data, lower = list(continuous = my_fn))
Function provided: loess
Obviously I am entering loess in the wrong place. Can anyone help me understand how to add the loess part in?
Note that my problem is different to this one, as I am asking how to implement loess in ggpairs since the params argument became deprecated.
Thanks very much.