0

I am trying to make a density plot out of 4000 rows (height.values), with 4 different categories (height.ind). this is the code i used.

library(ggplot2)
    
plom %>% 
  ggplot(aes(x = height.values, color=height.ind)) +
  geom_density() +
  labs(title = "height alimony")

I am able to get a density plot but there are a lot of lines instead of the 4 i want.

enter image description here

Anyone has an idea to fix it?

MrFlick
  • 195,160
  • 17
  • 277
  • 295
Michiel
  • 17
  • 4
  • 4
    Please share a sample of your `plom` data, best using `dput(head(plom))`. – Martin Gal Apr 11 '22 at 17:48
  • 3
    It seems like your data was imported incorrectly and `height.values` are not numeric values. When asking questions you should share your data in a [reproducible format](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) as well so we can run and test the code. – MrFlick Apr 11 '22 at 18:12
  • Try this: `plom %>% ggplot(aes(x = height.values, color=factor(height.ind))) + geom_density() + labs(title = "height alimony")` – TarJae Apr 11 '22 at 18:19

0 Answers0