Last active
January 30, 2023 14:33
-
-
Save nataberishvili/31d6156e635d652d40a38b8801eca4be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "EDA Dashboard" | |
output: | |
flexdashboard::flex_dashboard: | |
orientation: columns | |
vertical_layout: fill | |
runtime: shiny | |
--- | |
```{r setup, include=FALSE} | |
library(flexdashboard) | |
library(shiny) | |
library(dplyr) | |
library(plotly) | |
``` | |
```{r data} | |
data <- read.csv("BankChurners.csv") | |
Categorical.Variables = c("Gender", "Education_Level", "Marital_Status") | |
Numeric.Variables = c("Customer_Age", "Total_Trans_Ct", "Credit_Limit") | |
``` | |
Column {.sidebar data-width=200} | |
------------------------------------------------------------------- | |
```{r} | |
selectInput(inputId="categorical_variable", label = "Select Categorical Variable:", choices = Categorical.Variables, selected = Categorical.Variables[1]) | |
selectInput(inputId="numeric_variable", label = "Select Numeric Variable:", choices = Numeric.Variables, selected = Numeric.Variables[1]) | |
``` | |
Column {data-width=400} | |
------------------------------------------------------------------- | |
### **Box plot** shows the relationship between categorical and numeric variables | |
```{r} | |
renderPlotly({ | |
plot_ly(data, | |
x = ~data[[input$numeric_variable]], | |
color = ~data[[input$categorical_variable]], | |
colors = "Paired", | |
type = "box") %>% | |
layout(title = "", | |
xaxis = list(title = "" , | |
zeroline = FALSE)) | |
}) | |
``` | |
Column {data-width=400} | |
------------------------------------------------------------------- | |
### **Bar chart** shows the distribution of categorical veriable | |
```{r} | |
renderPlotly({ | |
data %>% | |
count(var = data[[input$categorical_variable]], name = "count") %>% | |
plot_ly( x = ~var, y = ~ count, type = "bar", marker = list(color = '#008ae6', | |
line = list(color = '#008ae6', width = 2)), hoverinfo = "x+y") %>% | |
add_text(text = ~paste0( " (", scales::percent(count/sum(count)),")"), | |
textposition = "bottom", | |
textfont = list(size = 12, color = "white"), | |
showlegend = FALSE) %>% | |
layout(xaxis = list(title = ""), yaxis = list(title = "")) | |
}) | |
``` | |
### **Histogram** shows the distribution of numeric variable | |
```{r} | |
renderPlotly({ | |
plot_ly(x = data[[input$numeric_variable]], type = "histogram", marker = list(color = "#008ae6", | |
line = list(color = "darkgray", | |
width = 1))) | |
}) | |
``` |
I have a list of errors and my code looks the same....
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I just want to say, your article on this was my reference when I was creating one of the dashboardshere. I just added a page for the dynamic data table. I did this for a Markdown training that we had to do at work. Thank you!
Geli