Advertisement
Guest User

Untitled

a guest
Aug 14th, 2020
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #before running your data should be in the format
  2. #Day,H00,H01,H02,H03,H04,H05,H06,H07,H08,H09,H10,H11,H12,H13,H14,H15,H16,H17,H18,H19,H20,H21,H22,H23
  3. #1,9102042,9104990,9107938,9110886,9113834,9116782,9119730,9122678,9125626,9128574,9131522,9134470,9137418,9140366,9143314,9146262,9149210,9152158,9155106,9158054,9161002,9163750,9166498,9169246
  4.  
  5. library(tidyverse)
  6. library(benford.analysis)
  7. data <- read.csv("hourly.csv")
  8.  
  9. data <- data %>%
  10. pivot_longer(
  11. cols = starts_with("H"),
  12. names_to = "hour",
  13. names_prefix = "H",
  14. values_to = "pledge",
  15. values_drop_na = TRUE
  16. )
  17.  
  18. increase <- diff(data$pledge)
  19. write.table(increase, file = "increase.csv", sep = ",", row.names = FALSE, col.names = FALSE)
  20.  
  21. m1 <- benford(increase, number.of.digits = 1)
  22. m1
  23. plot(m1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement