mainly we have 2 catagories: suppliment and dose. there are 6(2*3)dataset ###dplyr is more for data session.
library(plyr)
?ToothGrowth
funcion going to use is “ddply”. ddply(dataframe,used catagories, what going to do)
x<-ddply(ToothGrowth,
c("supp","dose"),
summarize,
MeanLength=mean(len))
install.packages(“ggplot2”) library(ggplot2)
ggplot(x,aes(x=dose,y=MeanLength))+
geom_line()
Group lines by supp. Since str(x) supp is factor, no need to group by supp ggplot(x,aes(x=dose,y=MeanLength,color=supp))+geom_line()
Otherwise:
ggplot(x,aes(x=dose,y=MeanLength,group=supp,color=supp))+
geom_line()
If black/white printing, change linetype to make it more obvious. add points in the transition even add shape demand in the ggplot(),then add shape in the geon_point which is the upper layor.
ggplot(x,aes(x=dose,y=MeanLength,group=supp,color=supp,linetype=supp,shape=supp))+
geom_line()+
geom_point(size=3,shape=3)
(Trick to know the shape of R)
pts<-data.frame(x=1:25,y=1:25)
pts
## x y
## 1 1 1
## 2 2 2
## 3 3 3
## 4 4 4
## 5 5 5
## 6 6 6
## 7 7 7
## 8 8 8
## 9 9 9
## 10 10 10
## 11 11 11
## 12 12 12
## 13 13 13
## 14 14 14
## 15 15 15
## 16 16 16
## 17 17 17
## 18 18 18
## 19 19 19
## 20 20 20
## 21 21 21
## 22 22 22
## 23 23 23
## 24 24 24
## 25 25 25
ggplot(pts,aes(x=x,y=y))+geom_point(shape=1:25)