Developing Data Products: Iris

Danilo Freire
17th November, 2014

What does the data product do?

My idea was very simple: to create an easy-to-use app that shows the bivariate relationships between variables in the famous iris dataset. The five variables can be seen with the following piece of code:

names(iris)
[1] "Sepal.Length" "Sepal.Width"  "Petal.Length" "Petal.Width" 
[5] "Species"     

Adding a line

There are two ways of adding a line to the graph, either using a simple linear model (lm), or a local regression smoothing line (loess). Here's an example: the relationship between Petal.Length and Petal.Width, with a loess smoother:

plot of chunk unnamed-chunk-2

Code

The server actually runs a very simple piece of code. It does the following

library(shiny)
library(ggplot2)
shinyServer (function (input, output) {    
    output$plot <- renderPlot ({        
        ggplot (iris, aes_string(input$x, input$y)) + 
            geom_point() + geom_smooth (method = input$smoother)
    })
})

Check it out

The app is hosted at the following address:

https://danilofreire.shinyapps.io/developing-data-products/