Data

Column

Bar-chart

## Column

---
title: "Flex Dashboards"
Author : Jeremi Heriyandi Saudi (20214920008)
output: 
  flexdashboard::flex_dashboard:
    vertical_layout: scroll
    theme: yeti
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(plotly)
library(ggplot2)
library(DT)
library(highcharter)
```


# Data

Column {data-width=650}
-----------------------------------------------------------------------

```{r}
# Importing Data
walmart <- read.csv('Walmart.csv')

```

```{r}
# Removing duplicates
walmart <- walmart %>% 
  distinct(Store, .keep_all = TRUE) %>% 
  rename(Store = 'Store')
```

```{r}
# This is going to be a datatable
walmart1 <- walmart %>% 
  filter(Store >= 5) %>% 
  arrange(desc(Store)) %>% 
  select(Store, Weekly_Sales,Fuel_Price,CPI,Unemployment)

datatable(walmart1, 
          options=list(scrollX=TRUE),
          caption = htmltools::tags$caption(
    style = 'caption-side: bottom; text-align: center;',
    '', htmltools::em('')
  ))
```


Bar-chart {data-orientation=rows}
=======================================================================


## Column {.tabset .tabset-fade data-height=520}
-----------------------------------------------------------------------

```{r fig.height=5}
# Colors
custom_colors <- viridis::turbo(n = 20)

# Most popular authors by reviews
walmart %>% 
  group_by(Store) %>% 
  summarise(Weekly_Sales = sum(Weekly_Sales)) %>% 
  arrange(desc(Weekly_Sales)) %>% 
  head(20) %>% 
  hchart('column', hcaes(x = Store, y = Weekly_Sales,color = custom_colors)) %>%   hc_add_theme(hc_theme_google()) %>% 
  hc_tooltip(pointFormat = '<b>Number of Reviews: </b> {point.y} <br>') %>% 
  hc_title(text = 'Most Popular Store',
           style = list(fontSize = '25px', fontWeight = 'bold')) %>% 
  hc_subtitle(text = 'By Number of Weekly Sales',
              style = list(fontSize = '16px')) %>% 
  hc_credits(enabled = TRUE, text = '@dsciencelabs')
  

```


```{r}
fig <- plot_ly(walmart1, x = ~Fuel_Price, y = ~Weekly_Sales, text = ~Store, type = 'scatter', mode = 'markers')
fig <- fig %>% layout(title = '',
         xaxis = list(showgrid = FALSE),
         yaxis = list(showgrid = FALSE))

fig
```