Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(xts)
- library(influxdbr)
- library(ggplot2)
- library(grid)
- library(gridExtra)
- require(lubridate)
- con <- influxdbr::influx_connection(host = "87.190.238.132",
- port = 8086,
- user = "default",
- pass = "password")
- dat <- read.csv(paste0(getwd(), "/common.csv"))
- one.month <- 30 * 24
- periods <- c(
- one.month * 18
- )
- dat <- dat[dat$Power_On_Hours < periods, ]
- dat <- dat[dat$site == "dresden2", ]
- dat$node<- droplevels(dat$node)
- needed.nodes <- levels(dat$node)
- df <- df[df$node %in% needed.nodes, ]
- df$node <- as.factor(df$node)
- date.collection <- as.Date("16-07-21")
- for(node in needed.nodes){
- node = needed.nodes[1]
- curr <- dat[dat$node == node, ]
- pow_on_hours <- curr$Power_On_Hours
- power_on_days <- round(pow_on_hours / 24, 0)
- dateofreplace <- date.collection
- day(dateofreplace) <- day(dateofreplace) - power_on_days
- monthbefore <- dateofreplace
- month(monthbefore) <- month(monthbefore) - 1
- dateofreplace <- format(dateofreplace, format="%Y-%m-%d")
- monthbefore <- format(monthbefore, format="%Y-%m-%d")
- time.bord <- paste0("time > \'20", monthbefore, "\' AND time < \'20", dateofreplace, "\'")
- where <- paste0("node=\'", node, "\' AND ", time.bord)
- print(where)
- node.data <- influx_select(
- con = con,
- db = "yearly",
- value = "time, value",
- from = "HDDTemp_temp_AVERAGE",
- where = where,
- order_desc = TRUE,
- return_xts = TRUE
- )$HDDTemp_temp_AVERAGE
- df <- as.data.frame(node.data)
- df$time = strptime(df$time, format = "%Y-%m-%dT%H:%M:%S")
- p <- ggplot(df, aes(x = time, y = value))
- p <- p + geom_line(size = 0.5)
- grid.draw(p)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement