Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. active <- structure(list(new_df = structure(c(1L, 12L, 23L, 26L, 27L, 28L,
  2. 29L, 30L, 31L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 13L,
  3. 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 24L, 25L), .Label = c("1",
  4. "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "2",
  5. "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "3",
  6. "30", "31", "4", "5", "6", "7", "8", "9"), class = "factor"),
  7. Date = structure(c(1422662400, 1425081600, 1427760000, 1430352000,
  8. 1433030400, 1435622400, 1438300800, 1440979200, 1443571200,
  9. 1446249600, 1448841600, 1451520000, 1454198400, 1456617600,
  10. 1459382400, 1461974400, 1464652800, 1467244800, 1469923200,
  11. 1472601600, 1475193600, 1477872000, 1480464000, 1483142400,
  12. 1485820800, 1488240000, 1490918400, 1493510400, 1496188800,
  13. 1498780800, 1501459200), class = c("POSIXct", "POSIXt"), tzone = "UTC"),
  14. value = c(65139, 66615, 66669, 67081, 67277, 67366, 67831,
  15. 65226, 64967, 64999, 65182, 65695, 68071, 68689, 68860, 69581,
  16. 69566, 68585, 67644, 67846, 67799, 67999, 68125, 68934, 68668,
  17. 68671, 68583, 68608, 68728, 69417, 69814), month = c(1L,
  18. 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L,
  19. 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 1L, 2L, 3L, 4L, 5L,
  20. 6L, 7L), months = c("јануари", "февруари", "март", "април",
  21. "мај", "јуни", "јули", "август", "септември", "октомври",
  22. "ноември", "декември", "јануари", "февруари", "март", "април",
  23. "мај", "јуни", "јули", "август", "септември", "октомври",
  24. "ноември", "декември", "јануари", "февруари", "март", "април",
  25. "мај", "јуни", "јули"), year = c(2015L, 2015L, 2015L, 2015L,
  26. 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2015L, 2016L,
  27. 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L, 2016L,
  28. 2016L, 2016L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L, 2017L
  29. ), year2 = c("15", "15", "15", "15", "15", "15", "15", "15",
  30. "15", "15", "15", "15", "16", "16", "16", "16", "16", "16",
  31. "16", "16", "16", "16", "16", "16", "17", "17", "17", "17",
  32. "17", "17", "17"), year_month = structure(1:31, .Label = c("1/15",
  33. "2/15", "3/15", "4/15", "5/15", "6/15", "7/15", "8/15", "9/15",
  34. "10/15", "11/15", "12/15", "1/16", "2/16", "3/16", "4/16",
  35. "5/16", "6/16", "7/16", "8/16", "9/16", "10/16", "11/16",
  36. "12/16", "1/17", "2/17", "3/17", "4/17", "5/17", "6/17",
  37. "7/17"), class = "factor"), Period = c("јануари/2015", "февруари/2015",
  38. "март/2015", "април/2015", "мај/2015", "јуни/2015", "јули/2015",
  39. "август/2015", "септември/2015", "октомври/2015", "ноември/2015",
  40. "декември/2015", "јануари/2016", "февруари/2016", "март/2016",
  41. "април/2016", "мај/2016", "јуни/2016", "јули/2016", "август/2016",
  42. "септември/2016", "октомври/2016", "ноември/2016", "декември/2016",
  43. "јануари/2017", "февруари/2017", "март/2017", "април/2017",
  44. "мај/2017", "јуни/2017", "јули/2017")), .Names = c("new_df",
  45. "Date", "value", "month", "months", "year", "year2", "year_month",
  46. "Period"), row.names = c(NA, -31L), class = "data.frame")
  47.  
  48. library(ggplot2)
  49. p <- ggplot(active) +
  50. geom_point(aes(as.factor(new_df), value, text = Period), size = 2, color="green") +
  51. geom_line(aes(as.factor(new_df), value, group = 1, alpha = 0.5), color = "deepskyblue4", group = 1) +
  52. theme_minimal()+
  53. xlab("") +
  54. ylab("") +
  55. theme(axis.text.x=element_blank())
  56.  
  57. library(plotly)
  58. ggplotly(p)
  59.  
  60. + facet_wrap( ~ year, ncol=3, scales = "free_x")
  61.  
  62. library(gtools)
  63. data$new_df <- with(data, factor(new_df, levels = gtools::mixedsort(unique(as.character(new_df)))))
  64.  
  65. ggplot(data) +
  66. geom_point(aes(new_df, value, text = Period), size = 2, color="green") +
  67. geom_line(aes(new_df, value, group = 1, alpha = 0.5), color = "deepskyblue4", group = 1) +
  68. theme_minimal()+ facet_wrap( ~ year, ncol=3, scales = "free_x") +
  69. xlab("") +
  70. ylab("") + theme(axis.text.x=element_blank())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement