-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ce20e2
commit 9eca7bf
Showing
4 changed files
with
3,378 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
title: "Developing Data Product Assignment 4" | ||
author: "Buğra Balkaç" | ||
date: "12/15/2020" | ||
output: ioslides_presentation | ||
--- | ||
|
||
## Introduction | ||
|
||
This presentation is part of the Developing Data Products Coursera.org course project submission. | ||
|
||
It is an R Presentation generated with RStudio. | ||
|
||
The Shiny application pitched by this presentation is at https://bugrabalkac.shinyapps.io/gapminder | ||
|
||
|
||
|
||
## Application Overview | ||
|
||
- The application is written in Shiny which is a web application framework for R | ||
- The source code consists of two files: server.R and ui.R | ||
- server.R includes the the server logic of a Shiny web application | ||
- ui.R includes the the user-interface definition, which uses the sidebarLayout template | ||
- The application is hosted on Rstudio's shiny server in the cloud (Shinyapps.io) | ||
|
||
## The Application contains: Left Panel | ||
|
||
- Label the main titel using a textInput | ||
- Change/determine the size of the plot points using a numericInput | ||
- Add a line of best fit using a checkboxInput | ||
- Change/determine the color of the plot points using a colourInput | ||
- Select data options using selectInput and sliderInput | ||
- download filtered data using a downloadButton | ||
|
||
## The Application contains: Main Panel | ||
|
||
There are two tabs in main panel as below: | ||
|
||
- Plot: This displays plot for corresponding dataframe | ||
- Table: This displays a searchable-interactive Table for corresponding dataframe | ||
|
||
|
||
## Ready to give it a try? | ||
|
||
Use the Shiny app at https://bugrabalkac.shinyapps.io/gapminder | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# | ||
# This is the server logic of a Shiny web application. You can run the | ||
# application by clicking 'Run App' above. | ||
# | ||
# Find out more about building applications with Shiny here: | ||
# | ||
# http://shiny.rstudio.com/ | ||
# | ||
|
||
library(plotly) | ||
library(colourpicker) | ||
library(ggplot2) | ||
library(gapminder) | ||
library(shinycustomloader) | ||
library(DT) | ||
|
||
server <- function(input, output) { | ||
filtered_data <- reactive({ | ||
data <- gapminder | ||
data <- subset( | ||
data, | ||
lifeExp >= input$life[1] & lifeExp <= input$life[2] | ||
) | ||
if (input$continent != "All") { | ||
data <- subset( | ||
data, | ||
continent == input$continent | ||
) | ||
} | ||
data | ||
}) | ||
|
||
output$table <- DT::renderDataTable({ | ||
data <- filtered_data() | ||
data | ||
}) | ||
|
||
output$download_data <- downloadHandler( | ||
filename = function() { | ||
paste("gapminder-data-", Sys.Date(), ".csv", sep="") | ||
}, | ||
content = function(file) { | ||
write.csv(filtered_data(), file) | ||
} | ||
) | ||
|
||
|
||
output$plot <- renderPlotly({ | ||
|
||
ggplotly({ | ||
data <- filtered_data() | ||
|
||
p <- ggplot(data, aes(gdpPercap, lifeExp)) + | ||
geom_point(size = input$size, col = input$color) + | ||
scale_x_log10() + | ||
ggtitle(input$title) + | ||
|
||
|
||
if (input$fit) { | ||
p <- p + geom_smooth(method = "lm") | ||
} | ||
p | ||
}) | ||
}) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# | ||
# This is the user-interface definition of a Shiny web application. You can | ||
# run the application by clicking 'Run App' above. | ||
# | ||
# Find out more about building applications with Shiny here: | ||
# | ||
# http://shiny.rstudio.com/ | ||
# | ||
|
||
library(plotly) | ||
library(colourpicker) | ||
library(ggplot2) | ||
library(gapminder) | ||
library(shinycustomloader) | ||
library(DT) | ||
|
||
ui <- fluidPage( | ||
|
||
# App title ---- | ||
titlePanel("Gapminder Data Visualization using Shiny and Plotly"), | ||
|
||
# Sidebar layout with input and output definitions ---- | ||
sidebarLayout( | ||
|
||
# Sidebar panel for inputs ---- | ||
sidebarPanel( | ||
|
||
# Input: Select the random distribution type ---- | ||
textInput("title", "Title", "GDP vs life exp"), | ||
numericInput("size", "Point size", 1, 1), | ||
checkboxInput("fit", "Add line of best fit", FALSE), | ||
colourInput("color", "Point color", value = "blue"), | ||
|
||
|
||
selectInput("continent", "Continent", | ||
choices = c("All", levels(gapminder$continent))), | ||
|
||
sliderInput(inputId = "life", label = "Life expectancy", | ||
min = 0, max = 120, | ||
value = c(30, 50)), | ||
downloadButton("download_data") | ||
|
||
|
||
), | ||
|
||
# Main panel for displaying outputs ---- | ||
mainPanel( | ||
|
||
# Output: Tabset w/ plot, summary, and table ---- | ||
tabsetPanel(type = "tabs", | ||
|
||
tabPanel("Plot", withLoader(plotlyOutput("plot")) ), | ||
tabPanel("Table", withLoader(DT::dataTableOutput("table"))) | ||
|
||
|
||
) | ||
|
||
) | ||
) | ||
) |