changes
This commit is contained in:
@ -4,19 +4,8 @@ library(dplyr)
|
|||||||
library(lubridate)
|
library(lubridate)
|
||||||
library(R.utils)
|
library(R.utils)
|
||||||
|
|
||||||
con <- dbConnect(RPostgres::Postgres(),
|
|
||||||
dbname='mainscnt',
|
|
||||||
host='db.mainscnt.eu',
|
|
||||||
user='wn')
|
|
||||||
|
|
||||||
|
|
||||||
START <- "2021-08-03 00:00:00"
|
|
||||||
INTERVAL <- 3600
|
|
||||||
|
|
||||||
for (offset in 0:23) {
|
|
||||||
startDate <- ymd_hms(START) + INTERVAL * offset
|
|
||||||
endDate <- startDate + INTERVAL
|
|
||||||
|
|
||||||
|
get_freq_df <- function(con, startDate, endDate) {
|
||||||
startStr <- strftime(startDate, "%Y-%m-%d %H:%M:%S", tz="UTC")
|
startStr <- strftime(startDate, "%Y-%m-%d %H:%M:%S", tz="UTC")
|
||||||
endStr <- strftime(endDate, "%Y-%m-%d %H:%M:%S", tz="UTC")
|
endStr <- strftime(endDate, "%Y-%m-%d %H:%M:%S", tz="UTC")
|
||||||
|
|
||||||
@ -30,8 +19,6 @@ for (offset in 0:23) {
|
|||||||
values_from = freq,
|
values_from = freq,
|
||||||
values_fn = mean)
|
values_fn = mean)
|
||||||
|
|
||||||
freq_wide$Linz_AT <- freq_wide$Linz_AT + 0.002
|
|
||||||
|
|
||||||
THRESHOLD <- 0.5
|
THRESHOLD <- 0.5
|
||||||
|
|
||||||
for (colIdx in 2:length(freq_wide)) {
|
for (colIdx in 2:length(freq_wide)) {
|
||||||
@ -44,15 +31,38 @@ for (offset in 0:23) {
|
|||||||
last <- current
|
last <- current
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (freq_wide)
|
||||||
|
}
|
||||||
|
|
||||||
|
con <- dbConnect(RPostgres::Postgres(),
|
||||||
|
dbname='mainscnt',
|
||||||
|
host='172.16.10.27',
|
||||||
|
user='wn')
|
||||||
|
|
||||||
|
|
||||||
|
START <- "2021-08-03 00:00:00"
|
||||||
|
INTERVAL <- 3600
|
||||||
|
|
||||||
|
for (offset in 0:0) {
|
||||||
|
startDate <- ymd_hms(START) + INTERVAL * offset
|
||||||
|
endDate <- startDate + INTERVAL
|
||||||
|
|
||||||
|
freq_wide <- get_freq_df(con, startDate, endDate)
|
||||||
|
|
||||||
|
for (colIdx in 2:length(freq_wide)) {
|
||||||
freq_wide <- freq_wide %>%
|
colName.mean <- paste("mean.w.o.", names(freq_wide)[colIdx], sep="")
|
||||||
rowwise() %>%
|
colName.diff <- paste(names(freq_wide)[colIdx], ".to.mean", sep="")
|
||||||
mutate(mad = mad(c_across(names(freq_wide)[-1]),
|
freq_wide <- freq_wide %>%
|
||||||
na.rm=TRUE))
|
rowwise() %>%
|
||||||
|
mutate(!!colName.mean := mean(c_across(names(freq_wide)[c(-1, - colIdx)]), na.rm=TRUE)) %>%
|
||||||
# print(summary(freq_wide))
|
mutate(!!colName.diff := abs())
|
||||||
printf("start: %s, end: %s, mad/cnt: %f\n", startStr, endStr, sum(freq_wide$mad) / length(freq_wide$mad))
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# print(summary(freq_wide))
|
||||||
}
|
}
|
||||||
|
|
||||||
dbDisconnect(con)
|
dbDisconnect(con)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user