Skip to content

Commit

Permalink
add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
bugrabalkac committed Dec 15, 2020
1 parent 8ce20e2 commit 9eca7bf
Show file tree
Hide file tree
Showing 4 changed files with 3,378 additions and 0 deletions.
3,207 changes: 3,207 additions & 0 deletions gapminder.html

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions gapminder.rmd
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

65 changes: 65 additions & 0 deletions server.R
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
})
})
}
60 changes: 60 additions & 0 deletions ui.R
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")))


)

)
)
)

0 comments on commit 9eca7bf

Please sign in to comment.