ddply output with ggplot

33 views
Skip to first unread message

surya.se...@gmail.com

unread,
Mar 31, 2017, 7:23:12 AM3/31/17
to ggplot2
Hi All,

I have taken titanic dataset and got the group wise counts as below.

Agegrp field is created by me

library(plyr)
survival_sum<-ddply(train_Titanic_1,.(Agegrp,Pclass),summarise,count=sum(cnt))   ## summary counts by P class and Age grp

However, after getting the above counts, I wanted to do a ggplot using the geom_point and geom_line connecting those points

I  have used the below statement, it works fine with geom_point. However, when I add geom_line() , it does not display line connecting those data points.

ggplot(survival_sum,aes(x=Agegrp,y=count,color=Pclass))+geom_point(aes(size=0.5)) +facet_grid(.~Survived)

Please help on how to incorporate the lines as well. I want to have a connecting line which goes through those points.

survival_sum is the summary of counts.
train_Titanic_1 is the data set.

Please let me know if any inputs are required on this.


Thanks in advance

---Surya
Reply all
Reply to author
Forward
0 new messages