Geom_density draws more than one line


I really don't know why but geom_desnity gives me more than line. Could you help me to explain it, please?

dulezitost <- structure(list(value = structure(c(1L, 2L, 4L, 2L, 2L, 4L, 3L, 
                                   2L, 4L, 1L, 3L, 1L, 1L, 3L, 2L, 5L, 3L, 3L, 1L, 2L, 4L, 4L, 3L, 
                                   2L, 3L, 3L, 1L, 3L, 5L, 4L, 4L, 4L, 3L, 4L, 2L, 2L, 5L, 1L, 2L, 
                                   4L, 4L, 4L, 3L, 1L, 5L, 4L, 5L, 4L, 3L, 2L, 4L, 2L, 5L, 3L, 4L, 
                                   4L, 2L, 5L, 2L, 3L, 4L, 4L, 3L, 1L, 5L, 2L, 3L, 4L, 2L, 4L, 3L, 
                                   5L, 5L, 4L, 2L, 1L, 4L, 5L, 3L, 2L, 4L, 4L, 5L, 4L, 4L, 4L, 2L, 
                                   5L, 4L, 4L, 4L, 1L, 4L, 2L, 4L, 4L, 5L, 2L, 5L, 2L, 3L, 5L, 1L, 
                                   2L, 2L, 4L, 5L, 4L, 2L, 5L, 2L, 5L, 3L, 3L, 4L, 3L, 2L, 3L, 4L, 
                                   4L, 4L, 3L, 3L, 4L, 5L, 4L, 2L, 2L, 3L, 2L, 3L, 4L, 3L, 2L, 2L, 
                                   4L, 3L, 3L, 2L, 5L, 5L, 2L, 5L, 3L, 4L, 4L, 3L, 5L, 4L, 3L, 4L, 
                                   2L, 4L, 4L, 2L), .Label = c("zásadně nesouhlasím", "nesouhlasím", 
                                                               "střed", "souhlasím", "zásadně souhlasím"), class = "factor")), row.names = c(NA, 
                                                                                                                                             -155L), class = c("tbl_df", "tbl", "data.frame"))

ggplot(data = dulezitost, aes(x=value))+


Manty thanks,


Your variable is a factor that one can convert into a character variable. I am pretty sure that you can only plot numeric data in a density plot.

1 Like

This topic was automatically closed 7 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.