I am getting lot of warning while plotting data using ggplot2.
Code below seems to work fine.
> library(tidyverse)
> ggplot(mpg) + geom_smooth(mapping = aes(x = displ, y = hwy, color = drv), se = FALSE)
`geom_smooth()` using method = 'loess'
The code that gives warnings:
> ggplot(mpg) + geom_smooth(mapping = aes(x = displ, y = hwy, color = class), se = FALSE)
`geom_smooth()` using method = 'loess'
Warning messages:
1: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, :
span too small. fewer data values than degrees of freedom.
2: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, :
pseudoinverse used at 5.6935
3: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, :
neighborhood radius 0.5065
4: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, :
reciprocal condition number 0
5: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, :
There are other near singularities as well. 0.65044
6: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, :
pseudoinverse used at 4.008
7: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, :
neighborhood radius 0.708
8: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, :
reciprocal condition number 0
9: In simpleLoess(y, x, w, span, degree = degree, parametric = parametric, :
There are other near singularities as well. 0.25
I can see the problem is with choosing the color. I got one explanation from Stackoverflow: a proper smoothing requires a continuous variable than a discreet one : But in my case, both variables are discreet. drv = f,r,4 and class = SUV, compact etc. Then I should warnings for both.