Hi! I'm trying to plot some data from a Haven labelled dataset using ggplot2. I'm grouping by "sex", a labelled int column. However, I get the following:
ggplot() + geom_line(data=dec_by_age_gender, mapping=aes(x=age_5yr,y=avg_dec,group=sex)) + scale_color_manual(values=c("red","green"))
Don't know how to automatically pick scale for object of type haven_labelled/vctrs_vctr/integer. Defaulting to continuous.
> ggplot() + geom_line(data=dec_by_age_gender, mapping=aes(x=age_5yr,y=avg_dec,group=sex)) + scale_color_manual(values=c("red","green"))
Don't know how to automatically pick scale for object of type haven_labelled/vctrs_vctr/integer. Defaulting to continuous.
> head(dec_by_age_gender)
# A tibble: 6 × 3
age_5yr sex avg_dec
<dbl> <int+lbl> <dbl>
1 20 1 [Male] 0.00357
2 20 2 [Female] 0.00320
3 25 1 [Male] 0.00421
4 25 2 [Female] 0.00406
5 30 1 [Male] 0.00473
6 30 2 [Female] 0.00453
> class(dec_by_age_gender)
[1] "tbl_df" "tbl" "data.frame"
> class(dec_by_age_gender$sex)
[1] "haven_labelled" "vctrs_vctr" "integer"
>
Since "sex" has the class "integer", shouldn't ggplot2 know to pick a discrete color scale for it?
Hi! I'm trying to plot some data from a Haven labelled dataset using ggplot2. I'm grouping by "sex", a labelled int column. However, I get the following:
Since "sex" has the class "integer", shouldn't ggplot2 know to pick a discrete color scale for it?