October 11, 2018

Introduction

This presentation is created as part of the requirement for the Coursera Developing Data Products Course. Objectives of the assignment are to ensure sound understanding of the following concepts.

  • Use shiny to build data product application
  • Use R-Presentation to create data product related presentations

The Application

Enables the user to download table data in shiny - CSV, TXT, DOC formats

  • Using downloadButton & donwloadHandler functions.

The following 5 datasets are available for download:

  • iris dataset, mtcars dataset, faithful dataset, trees dataset, faithful dataset.
  • The source code consists of two files: server.R and ui.R
  • The application is hosted on Rstudio's shiny server in the cloud (Shinyapps.io)

Slide with ui.R code

library(shiny)

# Define UI for data download app ----
fluidPage(
  
  # App title ----
  titlePanel("Downloading Data using downloadbutton() and downloadHandler()"),
  
  # Sidebar layout with input and output definitions ----
  sidebarLayout(
    
    # Sidebar panel for inputs ----
    sidebarPanel(
      
      # Input: Choose dataset ----
      selectInput("dataset", "Choose a dataset:",
                  choices = c("mtcars", "pressure", "iris", 
                              "faithful","trees")),
      br(),
      helpText("Select the download format"),
      radioButtons("type", "Format type:",
                   choices = c("Excel (CSV)", "Text(TSV)", "Text (Space Seperated)", 
                               "Doc")),
      br(),
      helpText("Click on the download button download the dataset observation"),
      
      # Button
      downloadButton('downloadData', 'Download')
      
    ),
    
    # Main panel for displaying outputs ----
    mainPanel(
      
      tableOutput('table')
      
    )
    
  )
)

References

The application pitched by this presentation is located at my Shiny app page

The source codes for ui.R and server.R files are also available on the GitHub repo