The parameter "method" does not exist in qplot in R?

The documentation for qplot does not contain the method parameter. The error I am getting is

> qplot(displ, hwy, data = mpg, geom=c("point", "smooth"),facets=.~drv,method="loess") Error: Unknown parameters: method 

My R version is 3.2.1 and ggplot2 version is 2.0.0 if that helps.

+6
source share
2 answers

There is no need for a method since geom_smooth() accepts loess

 qplot(displ, hwy, data = mpg, geom=c("point", "smooth"),facets=.~drv) 

If geom = "smooth", the loess fit line and confidence limits are added by default. When the number of observations exceeds 1000, an effective smoothing algorithm is used more. Methods include lm for regression, gam for generalized supplement models, and rlm for robust regression. The formula parameter gives the correspondence form.

enter image description here

+5
source

Welcome to SO. You receive an error message due to an update in ggplot2 ; the tutorial you are looking at was probably from an older version. You will see this in many places on the Internet.

For reference: the purpose of the exercise, the exact (or minimal working example) code and the output is usually published on this forum, and the efforts made at the stage where they got stuck are discussed. This helps other members give a more consistent answer.

+8
source

All Articles