statistics/time_series.R

28 lines
764 B
R
Raw Normal View History

2022-09-03 23:03:05 -04:00
library(stringi)
result <- dbSendQuery(conn, query_get_players)
players <- fetch(result)
if (nrow(players) > 0) {
for (row in 1:nrow(players)) { # nolint
id <- players[row, "id"]
name <- players[row, "name"]
filename <- stri_trans_general(str = name, id = "Latin-ASCII")
query <- query_game_coin_vs_time_start
query <- paste(query, id)
query <- paste(query, query_game_coin_vs_time_end)
data <- dbGetQuery(conn, query)
time_series <- ts(data[2], start = 0, frequency = 1)
png(file = paste("out/", paste(filename, ".png", sep = ""), sep = ""))
plot(time_series, main = name, yaxt = "n")
axis(2, pretty(c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), n = 12))
}
}