How can I create a plot with ggplot when my answers are TRUE or FALSE?
This is my code:
t.obese<-master1%>%
filter(Income>0,obese==TRUE)%>%
select(Income,obese)
> head(t.obese)
Income obese
1 21600 TRUE
2 4000 TRUE
3 12720 TRUE
4 26772 TRUE
when I am trying to create a plot , r tells me " Don't know how to automatically pick scale for object of type haven_labelled/vctrs_vctr/double. Defaulting to continuous. Fehler: stat_count() can only have an x or y aesthetic."
Thank you!
> dput(t.obese[1:10, ])
structure(list(Income = structure(c(1944, 4000, 16000, 19200,
22800, 21600, 18000, 18000, 2000, 18000), label = "Wages,Salary from main job", format.stata = "%42.0g", labels = c(`[-5] in Fragebogenversion nicht enthalten` = -5,
`[-2] trifft nicht zu` = -2), class = c("haven_labelled", "vctrs_vctr",
"double")), obese = c(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE)), row.names = c(NA, 10L), class = "data.frame")
If you want to compare Income distribution across obesity, then you need both obese = TRUE and obese = FALSE, so you can do the comparison
I randomly created an
non_obese
dataset just to do the comparison. Also, I removed thehaven_labelled
class for theIncome
since it was causing some issues in thereprex
rendering [usinghaven::zap_labels()
Anyway, hope the following will help you get started
Created on 2020-12-03 by the reprex package (v0.3.0)