Adatfile: atm.csv

Betöltése:

df <- read.csv('/files/2012/11/atm.csv')

Modell keresése:

df$mday <- 1:30
df$wday <- rep(1:7, 15)[1:90]
range(df$atm[1:7])
range(df$atm[22:28])
mean(df$atm[1:7])
mean(df$atm[22:28])
f <- function(x) 50000-50000/30*x
df$mtrend <- f(df$mday)
plot(df$atm, type = "l")
lines(df$mtrend, col = "red")
 
df$wtrend <- df$atm - df$mtrend
plot(df$wtrend, type = "l")
f <- function(x) 75000-75000/30*x
df$mtrend <- f(df$mday)
df$wtrend <- df$atm - df$mtrend
plot(df$wtrend, type = "l")
 
df$p <- df$wtrend + df$mtrend

Egy évre előrevetítve:

df2 <- data.frame(nap = 1:360)
df2$mday <- 1:30
df2$wday <- rep(1:7, 52)[1:360]
df2$mtrend <- df$mtrend[1:30]
df2$wtrend <- rep(df$wtrend[1:7], 52)[1:360]
str(df2)
df2$atm <- df2$mtrend + df2$wtrend
plot(df2$atm, type = "l")
lines(df$p, col = "red")