Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. breaks counts.x counts.y
  2. 1 -20 1 1
  3. 2 -15 0 1
  4. 3 -10 0 5
  5. 4 -5 4 18
  6. 5 0 13 27
  7. 6 5 18 25
  8. 7 10 9 12
  9. 8 15 2 1
  10. 9 20 1 7
  11. 10 25 NA 0
  12. 11 30 NA 1
  13.  
  14. d=melt(d,id=breaks)
  15. Error in varnames[id.vars] :
  16. only 0's may be mixed with negative subscripts
  17.  
  18. library(reshape)
  19. library(ggplot2)
  20.  
  21. d <- data.frame(breaks = c(-20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30),
  22. counts.x = c(1, 0, 0 ,4 , 13, 18, 9, 2, 1, NA, NA),
  23. counts.y = c(1, 1, 5, 18, 27, 25, 12, 1, 7 , 0, 1))
  24.  
  25. d <- melt(d, id = "breaks")
  26.  
  27. ggplot(d, aes(x = breaks, y = value)) + geom_point(aes(colour = variable)) +
  28. labs(title = "Bins vs. Counts", x = "Bins", y = "Counts") +
  29. theme(plot.title = element_text(face = "bold"))
  30.  
  31. library(tidyr)
  32. d <- gather(d,"variable","value",2:3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement