Last active
April 5, 2021 22:09
-
-
Save honzasterba/5dbc4b24bc8a8a0745961c2235345fea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(plyr) | |
data <- read.csv("~/Downloads/ockovaci-mista.csv") | |
data$datum <- as.Date(data$datum) | |
data$week <- strftime(data$datum, format = "%Y-%V") | |
prvni.davka <- data[ data$poradi_davky == 1,] | |
by.week <- ddply(prvni.davka, .(week), .fun = function(part) { | |
data.frame(cnt = nrow(part)) | |
}) | |
add <- by.week[by.week$week == "2021-53", "cnt"] | |
by.week[by.week$week == "2020-53", "cnt"] = add + by.week[by.week$week == "2020-53", "cnt"] | |
by.week <- by.week[by.week$week != "2021-53", ] | |
by.week$ord <- c() | |
for (i in 1:nrow(by.week)) { | |
by.week$ord[i] <- i | |
} | |
linearMod <- lm(cnt ~ ord, by.week) | |
weeks <- data.frame( | |
ord = 16:53 | |
) | |
preds <- data.frame( | |
ord = weeks$ord, | |
cnt = predict(linearMod, weeks) | |
) | |
plot( | |
by.week$ord, by.week$cnt, | |
xlim=c(min(by.week$ord), max(preds$ord)), | |
ylim=c(min(by.week$cnt), max(preds$cnt)), | |
) | |
points(preds$ord, preds$cnt, col="red") | |
done <- sum(by.week$cnt) | |
for (i in 1:nrow(preds)) { | |
pred <- sum(preds[1:i, "cnt"]) | |
cat(paste(preds[i, "ord"], "week->", format(done + pred, big.mark=" "), "\n")) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 week-> 1 406 279 | |
17 week-> 1 590 883 | |
18 week-> 1 786 864 | |
19 week-> 1 994 224 | |
20 week-> 2 212 961 | |
21 week-> 2 443 076 | |
22 week-> 2 684 569 | |
23 week-> 2 937 440 | |
24 week-> 3 201 688 | |
25 week-> 3 477 314 | |
26 week-> 3 764 318 | |
27 week-> 4 062 700 | |
28 week-> 4 372 460 | |
29 week-> 4 693 597 | |
30 week-> 5 026 113 | |
31 week-> 5 370 006 | |
32 week-> 5 725 277 | |
33 week-> 6 091 925 | |
34 week-> 6 469 952 | |
35 week-> 6 859 356 | |
36 week-> 7 260 138 | |
37 week-> 7 672 298 | |
38 week-> 8 095 836 | |
39 week-> 8 530 752 | |
40 week-> 8 977 045 | |
41 week-> 9 434 716 | |
42 week-> 9 903 765 | |
43 week-> 10 384 192 | |
44 week-> 10 875 996 | |
45 week-> 11 379 179 | |
46 week-> 11 893 739 | |
47 week-> 12 419 677 | |
48 week-> 12 956 993 | |
49 week-> 13 505 686 | |
50 week-> 14 065 758 | |
51 week-> 14 637 207 | |
52 week-> 15 220 034 | |
53 week-> 15 814 239 |
Author
honzasterba
commented
Apr 5, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment