Aesthetics must be either length 1 or the same as the data (2044): y

for reference I am using library(gssr)

Hi, I am doing homework for a class, and I have been stuck on this forever!

Can I get some help? ASAP!

ggplot(gss_2010, (aes(x=mntlhlth, y=abany, color=factor(happy))))+geom_jitter(alpha=0.4, height=5)+geom_smooth(method=lm,se=F, linetype="dashes")+geom_smooth(method=glm, method.args=list(family=binomial),se=F)

keep getting an error: Aesthetics must be either length 1 or the same as the data (2044): y

Hello. It probably has something to do with the variables being factor variables.

library(gssr) # remotes::install_github("kjhealy/gssr")
library(ggplot2)

gss_2010 <- gss_get_yr(2010) 

ggplot(gss_2010, (aes(x=mntlhlth, y=abany, color=factor(happy)))) + 
  geom_jitter(alpha=0.4, height=5) + 
  geom_smooth(method=lm,se=F, linetype="dashes") +
  geom_smooth(method=glm, method.args=list(family=binomial),se=F)

I got a different error anyway:

Don't know how to automatically pick scale for object of type haven_labelled/vctrs_vctr/double. Defaulting to continuous.
Don't know how to automatically pick scale for object of type haven_labelled/vctrs_vctr/double. Defaulting to continuous.
geom_smooth() using formula 'y ~ x'
geom_smooth() using formula 'y ~ x'
Error in grid.Call.graphics(C_lines, x$x, x$y, index, x$arrow) :
invalid hex digit in 'color' or 'lty'
In addition: Warning messages:
1: Removed 1318 rows containing non-finite values (stat_smooth).
2: Removed 1318 rows containing non-finite values (stat_smooth).
3: Computation failed in stat_smooth():
y values must be 0 <= y <= 1
4: Removed 1318 rows containing missing values (geom_point).

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.