Advertisement
Guest User

Untitled

a guest
Feb 9th, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.80 KB | None | 0 0
  1. a="year total  boy girl
  2. 1   106 16526 9377 7149
  3. 2   105 16499 9403 7096
  4. 3   104 16532 9441 7091
  5. 4   103 16505 9425 7080
  6. 5   102 16575 9456 7119
  7. 6   101 16915 9609 7306
  8. 7   100 17277 9703 7574
  9. 8    99 17514 9770 7744
  10. 9    98 17492 9774 7718
  11. 10   97 17152 9504 7648"
  12.  
  13. aa=read.table(text=a)
  14.  
  15. ggplot(aa,aes(x=year,y=value,col=variable))+
  16.  geom_point(aes(y=total, col = "total"))+
  17.  geom_line(aes(y=total, col = "total"))+
  18.  geom_point(aes(y=boy,col="boy"))+
  19.  geom_line(aes(y=boy,col="boy"))+
  20.  geom_point(aes(y=girl,col="girl"))+
  21.  geom_line(aes(y=girl,col="girl"))+
  22.  scale_color_manual(values=c("red","blue","black" ))
  23.  
  24. library(reshape2)
  25. aaa=melt(aa,id="year")
  26.  
  27. ggplot(aes(x=year,y=value,color=variable),data=aaa)+
  28.  geom_point()+geom_line()+
  29.  scale_color_manual(values=c("black", "red", "blue"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement