Reputation: 53
Here is my data set
I want to plot a graph showing the Probability density function for the variable quality of the division on the type of wine.
I try this:
library(ggplot2)
db <- dbeta(wines$quality, 1, 1)
qplot(wines$quality, db, geom="line")
but it plot flat line.
ok, i think my code don't have any sens. I want to do somethink lie that: Example x-quality of wines(dry,semi-dry....)
What can I do?
Upvotes: 3
Views: 19150
Reputation: 8763
Is this what you want?
ggplot(wines) + geom_density(aes(quality))
EDIT:
I see your point, but probably you just need to rescale the y values (am I correct?) so is not this what you're after? changed the image
ggplot(wines[-4381,]) + geom_density(aes(x=quality)) +
facet_wrap(~sweetnes)
or all in one with different fill
ggplot(wines) + geom_density(aes(x=quality, fill=sweetnes))
Upvotes: 10