Adding geom_point
as suggested by @zx8754 gives me a scatter plot. There is still the warning you reported which is related to some of your variables being of type haven_labelled
, so I guess you imported your data from SPSS.
To get rid of this warning you could convert your variables to R factors using haven::as_factor
. Probably it would be best to do that for the whole dataset after importing your data.
diagnoza <- structure(list(Plecc = c(2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 1, 2,
1, 1, 1, 1, 2, 1, 1, 2), P32.01 = structure(c(3, 4, 5, 5, 5,
5, 5, 4, 3, 5, 3, 4, 3, 4, 5, 5, 5, 3, 4, 5), label = "P32.01. odpoczynek w domu (oglądanie TV)", format.spss = "F1.0", display_width = 12L, labels = c(Nigdy = 1,
Rzadko = 2, `Od czasu do czasu` = 3, Często = 4, `Bardzo często` = 5
), class = c("haven_labelled", "vctrs_vctr", "double"))), row.names = c(NA,
-20L), class = c("tbl_df", "tbl", "data.frame"))
library(haven)
library(ggplot2)
# Convert labelled vector to a factor
diagnoza$P32.01 <- haven::as_factor(diagnoza$P32.01)
ggplot(data = diagnoza, aes(x = Plecc, y = P32.01)) +
geom_point()
ggplot(...) + geom_point()
– zx8754dput(diagnoza)
into the console and copy & paste the output starting withstructure(....
into your post. If your dataset has a lot of observations you could dodput(head(diagnoza, 20))
for the first twenty rows of data ordput(head(diagnoza[, c("Plecc", "P32.01")], 20))
for only the cols used in the plot. – stefan