Individual Counts

Cumulative Counts

---
title: "Top 10 Retweets: Charlotte Protests"
output: 
  flexdashboard::flex_dashboard:
    social: menu
    source: embed
---


```{r setup, include=FALSE}
libraries <- c("flexdashboard","tidyverse", "dygraphs", "xts", "reshape2","lubridate")

# first time, to install packages run install.packages(libraries)
lapply(libraries, require, character.only = TRUE)

count <- read_csv("./count.csv")

#tweets$text <- iconv(tweets$text, "latin1", "ASCII", sub="")
#agg$newtime <- paste0(substr(agg$datetime, 1, 13), ":00:00 EDT")
```

### Individual Counts {data-height=500}

```{r}
#agg$estTime <- ymd_hms(agg$newtime, tz = "EDT")
#aqm <- melt(agg, id=c("estTime","object.id"), measure.vars = c("Count"), na.rm=TRUE)
#count <- dcast(aqm, estTime ~ object.id, fun.aggregate = sum)
#count$estTime <- with_tz(count$estTime, tz = "EDT")

tweet.time <- xts(
  x = count[,2:11],
  order.by = count$estTime,
  tz = "EDT"
)

 dygraph(tweet.time,  main = "Tweet Counts", group = "combine") %>%
    dyLegend(show = "onmouseover") %>%
    dyOptions(colors = RColorBrewer::brewer.pal(8, "Dark2"), includeZero = TRUE) %>%
    dyAxis("x", drawGrid = FALSE) %>%
    dyAxis("y", label = "Tweet Count") 
```


### Cumulative Counts {data-height=500}

```{r}
#initialize
cumsum <- count

for (i in 2:11){
  cumsum[,i] <- cumsum(count[,i])
}

cum.tweet.time <- xts(
  x = cumsum[,2:11],
  order.by = cumsum$estTime,
  tz = "EDT"
)

 dygraph(cum.tweet.time,  main = "Tweet Counts", group = "combine") %>%
    dyLegend(show = "onmouseover") %>%
    dyOptions(colors = RColorBrewer::brewer.pal(8, "Dark2"), includeZero = TRUE) %>%
    dyAxis("x", drawGrid = FALSE) %>%
    dyAxis("y", label = "Tweet Count") 
```