Column

#1hari1oknum

Sales by State

Column

#1hari1oknum

#PercumaLaporPolisi

---
title: "Report Tagar Twitter"
author: "Gilang"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    social: menu
    source_code: embed
---

```{r setup, include=FALSE}
library(rtweet)
library(tidyverse)
library(lubridate)
library(glue)
library(plotly)
library(wordcloud2)
library(tm)
library(flexdashboard)
library(readxl)
library(highcharter)

dat11 <- read_excel("dat11.xlsx")
dat21 <- read_excel("dat21.xlsx")

```

Column {data-width=600}
-----------------------------------------------------------------------

### #1hari1oknum

```{r}
#plot1
dat11 %>%
  group_by(is_retweet) %>%
  count(tgl) %>%
  ggplot(aes(x = factor(tgl, levels = c("30-06","01-07","02-07",
                                        "03-07","04-07","05-07",
                                        "06-07","07-07","08-07")), 
                        y = n, col = is_retweet, group = is_retweet,
             text = glue::glue("Total : {n}
                               is_rtweet = {is_retweet}"))) + 
  geom_line(size = 1) + theme_light() + 
  scale_color_manual(values = c("#abebc6","#28b463")) +
  labs(x = NULL, y = NULL, title = "Tagar #1hari1oknum di Twitter", 
       subtitle = "30/06/2022-08/07/2022") +
  theme(legend.position = "none",
        plot.title = element_text(hjust = .5)) -> plot1


ggplotly(plot1,tooltip = "text") %>%
  config(displayModeBar = F)
```

### Sales by State

```{r}
#plot2
dat21 %>%
  group_by(is_retweet) %>%
  count(tgl) %>%
  ggplot(aes(x = factor(tgl, levels = c("29-06","30-06","01-07","02-07",
                                        "03-07","04-07","05-07",
                                        "06-07","07-07","08-07")), 
                        y = n, col = is_retweet, group = is_retweet,
             text = glue::glue("Total : {n}
                               is_rtweet = {is_retweet}"))) + 
  geom_line(size = 1) + theme_light() + 
  scale_color_manual(values = c("#abebc6","#28b463")) +
  labs(x = NULL, y = NULL, title = "Tagar #PercumaLaporPolisi di Twitter", 
       subtitle = "29/06/2022-08/07/2022") +
  theme(legend.position = "none",
        plot.title = element_text(hjust = .5)) -> plot2

ggplotly(plot2,tooltip = "text") %>%
  config(displayModeBar = F)
```

Column {.tabset data-width=400}
-----------------------------------------------------------------------

### #1hari1oknum

```{r, fig.keep='none'}



text_dat1 = dat11$text
# Create a corpus  
docs1 <- Corpus(VectorSource(text_dat1))


docs1 <- docs1 %>%
  tm_map(removePunctuation) %>%
  tm_map(stripWhitespace)
docs1 <- tm_map(docs1, content_transformer(tolower))


dtm1 <- TermDocumentMatrix(docs1) 
matrix1 <- as.matrix(dtm1) 
words1 <- sort(rowSums(matrix1),decreasing=TRUE) 
df1 <- data.frame(word = names(words1),freq=words1)

df1 %>%
  slice(2:15) %>%
  hchart("bar",
         hcaes(x = word, y = freq),
         color = "lightgray", borderColor = "black")
```

### #PercumaLaporPolisi

```{r}

text_dat2 = dat21$text
# Create a corpus  
docs2 <- Corpus(VectorSource(text_dat2))


docs2 <- docs2 %>%
  tm_map(removeNumbers) %>%
  tm_map(removePunctuation) %>%
  tm_map(stripWhitespace)
docs2 <- tm_map(docs2, content_transformer(tolower))


dtm2 <- TermDocumentMatrix(docs2) 
matrix2 <- as.matrix(dtm2) 
words2 <- sort(rowSums(matrix2),decreasing=TRUE) 
df2 <- data.frame(word = names(words2),freq=words2)


wordcloud2(data=df2, size=1.6, color='random-dark')
```