I have a random vector, and trying to make density plot of it using ggplot here is the vector
fridayKlient1<-c(134 ,135, 133, 137, 136)
then i used density over it
res<-density(data)
then i try to convert the result of density to data.frame to prepare for ploting:
framer<-function(data){return (data.frame(y=data$y, x=data$x)) }
and then plot it
res<-framer(density(fridayKlient1))
ggplot() +
geom_density(aes(x=x,y=y), colour="red" , data=res)
. but it complains with:
ggplot2: object 'y' not found
str(res)to see what else is in the list). I think you just needres1 = data.frame(res$x, res$y). - eipi10plot(density(data))- G5Wggplot() + geom_density- Sal-laS