README.rd 1.07 KB
Newer Older
andy.disch's avatar
andy.disch committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
---
title: "datValX_dataIllustration"
author: "adisch"
date: "September 11, 2018"
output: html_document
---

```{r setup, include = FALSE}

rm(list = ls())

library(DatapoolR)
library(lubridate)
library(dplyr)
library(reshape2)
library(ggplot2)
library(xts)
library(dygraphs)

```

# Illustration of the data collected in UWO

```{r export}

source.name <- list.sources()$instance
parameter.name <- "flow rate"
from <- "2017-06-22 00:00:00"
to <- "2017-06-29 23:59:59"
step <- "5 minutes"

df <- data.frame(time = seq.POSIXt(as.POSIXct(from), as.POSIXct(to), by = "5 min"))

for(i in c(35, 40, 41, 42)){
  
  tmp <- tryCatch(signals.of.source(source.name[i], from, to, parameter.name)[ ,1:2], 
                                   error = function(e) { return(NA) })
  
  if(!is.na(tmp)) {

    tmp$time <- round_date(tmp$time, step)
    
    df <- left_join(df, tmp, by = "time")
  
  }
  
}

dygraph(xts(df[ ,-1], order.by = df$time)) %>%
        dyOptions(useDataTimezone = TRUE) %>% 
        dyRangeSelector() %>%
        dyLegend(width = 0) %>%
        dyOptions(axisLineWidth = 1.5)

```