library(opensignauxfaibles) library(dplyr) library(ggplot2) database_signauxfaibles <- database_connect()
tbl(database_signauxfaibles, "table_effectif") %>% collect(n = 5) %>% glimpse()
tbl(database_signauxfaibles, "table_effectif") %>% count(period) %>% collect() %>% mutate(date = lubridate::ymd(paste0(period, "-01"))) %>% arrange(desc(date))
tbl(database_signauxfaibles, "table_apart_consommee") %>% collect() %>% glimpse()
tbl(database_signauxfaibles, "table_apart_consommee") %>% filter(is.na(date) == FALSE) %>% group_by(date) %>% summarise( heures_consommees = sum(heures_consommees, na.rm = TRUE) ) %>% collect() %>% mutate(year = lubridate::year(date)) %>% ggplot() + geom_col( mapping = aes(x = date, y = heures_consommees), col = "white" )
tbl(src = database_signauxfaibles, "table_ccsv") %>% collect() %>% mutate(ym = lubridate::ymd( paste0( lubridate::year(date_creation), "-", lubridate::month(date_creation), "-01") ) ) %>% count(ym) %>% ggplot() + geom_col( mapping = aes(x = ym, y = n) ) + scale_x_date()
dplyr::tbl(database_signauxfaibles, "table_debit") %>% filter(periodicity == "monthly") %>% dplyr::count(period) %>% dplyr::collect() %>% dplyr::mutate(date = lubridate::ymd(paste0(period, "-01"))) %>% dplyr::arrange(desc(date)) %>% ggplot2::ggplot() + ggplot2::geom_col( mapping = aes(x = date, y = n), col = "white" ) + ggplot2::scale_x_date( limits = lubridate::ymd(c("2010-01-01", "2017-12-01")) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.