Developing Data Products: Pitch Presentation

Francesco Aldo Tucci
2021-04-16

Idea

This project, which concludes the Developing Data Products in the Data Science specialization offered on Coursera by Johns Hopkins University, develops a simple app useful for fast and reliable Exploratory Data Analysis.

The app only requires to properly clean and format the data.

It needs a clear partition of the dataset into numerical and categorical variables, which will constitute the two separate set of inputs used by the app.

It creates a boxplot for the numeric variable input, split into groups according to the levels of the factor input.

I use the R built-in 'mtcars' dataset to show how it works.

Data Processing

The following code is the minimal code needed to clean, pre-process and prepare the data for our needs.

library(datasets) ; data("mtcars") 
mtcars$cyl  <- factor(mtcars$cyl, levels = c(4, 6, 8)) 
mtcars$vs   <- factor(mtcars$vs, labels = c("V", "S")) 
mtcars$gear <- factor(mtcars$gear, levels = c(3, 4, 5)) 
mtcars$carb <- factor(mtcars$carb, levels = c(1, 2, 3, 4, 6, 8)) 
mtcars$am <- factor(mtcars$am, labels = c("Automatic", "Manual"))
vector.numeric <- c("mpg", "disp", "hp", "drat", "wt", "qsec") 
vector.cat     <- c("cyl", "vs", "am", "gear", "carb") 

ui.R Code

Here I present the ui.R code (only a few details are omitted for clarity).

library(shiny) 
shinyUI(fluidPage( 
            titlePanel("Create a boxplot of a 
                       numerical variable by group"), 
            helpText("[OMISSIS]"), 
            sidebarLayout( 
                sidebarPanel( 
                    selectInput("numeric", "Choose numeric 
                                variable", 
                                choices = vector.numeric), 
                    selectInput("category", "Choose factor 
                                variable", 
                                choices = vector.cat) ), 
                mainPanel(plotOutput(outputId = "Boxplot") )  
) ) ) 

server.R Code

Here I present the server.R code (again, a few details are omitted for clarity).

library(shiny) 
shinyServer(function(input, output) { 
                output$Boxplot <- renderPlot({ 
                          y <- mtcars[, input$numeric] 
                          x <- mtcars[, input$category] 
                          plot(x = x, y = y) 
                })  
}) 

App Preview

The app is available at https://francescoaldo.shinyapps.io/c9_FINAL/. Here a nice screenshot.

plot of chunk SCREENSHOT