knitr::opts_chunk$set(echo = TRUE, 
                      fig.align = "center")
Sys.setlocale("LC_TIME", "C")

Let's start !

library(EcoCounteR)
library(leaflet)
library(htmltools)
library(dplyr)
library(ggplot2)
Rostock <- c(100037011, 100005392, 100037010, 100034887, 100017341, 100005395, 100005394, 100005393,
       100011605, 100037012)
info <- get_EcoCounter_info(Rostock)

info
locations <- get_EcoCounter_location(Rostock)

Show installations on map

leaflet(locations) %>%
  addProviderTiles(providers$OpenStreetMap) %>%
  addTiles() %>%
  addMarkers(~long, ~lat, popup = ~htmltools::htmlEscape(name), label = ~htmltools::htmlEscape(as.character(idParent)))

Load data for bicycles

Am_Strande_IN_complete <- get_EcoCounter_data(101005395, from = "20130701", to = "20180831", step = 6) %>% 
  mutate(Type = "IN")
Am_Strande_OUT_complete <- get_EcoCounter_data(102005395, from = "20130701", to = "20180831", step = 6) %>% 
  mutate(Type = "OUT")

Am_Strande_complete <- bind_rows(Am_Strande_IN_complete, Am_Strande_OUT_complete) 
Am_Strande_monthly <- 
Am_Strande_complete %>%
  mutate(weekday = wday(date, label = TRUE),
         year = year(date),
         month = month(date, label = TRUE)) %>% 
  na.omit()

ggplot(Am_Strande_monthly, aes(x = month, y = comptage, fill = Type)) +
  geom_bar(stat = "identity", position = "dodge") +
  facet_wrap(~year) +
  theme(legend.position = "bottom",
        axis.text.x = element_text(angle = 45, hjust = 1)) +
  xlab("Month") + 
  ylab("Amount")

Look into details

Am_Strande_OUT_detail <- get_EcoCounter_data(102005395, from = "20160701", step = 3)

Am_Strande_OUT_detail %>% 
  top_n(10, comptage) %>% 
  arrange(desc(comptage))


JohannesFriedrich/EcoCounteR documentation built on June 16, 2020, 11:41 p.m.