Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
---
title: 'Iris: Sepal-Ratio Modeling'
author: "Bastiaan Quast"
date: "Thursday, July 18, 2014"
output:
ioslides_presentation:
keep_md: yes
transition: faster
runtime: shiny
---
# We want to model sepal ratios, do we need separate models for each species?
## Iris dataset
- Included in R package **datasets**
- Originally by Fisher or Anderson
- Measurements for **petal** and **sepal** width and length
- Fifty flowers of three species
- Setosa
- Versicolor
- Virginica
```{r}
str(iris)
```
## LOESS Model
- **Lo**cally W**e**ighted **S**catterplot **S**moothing
- [more info on LOESS](http://en.wikipedia.org/wiki/Local_regression)
- General model and species-specific models
- Standard Error bands
- Grey band for general model
- Coloured bands for respective species
- Adjustable 'wobblyness' of models
- Adjustable point size and opacity
## Results
```{r echo=FALSE, message=FALSE}
# load the ggvis package
library(ggvis)
# load the dplyr package
# for use of magrittr pipe: %>%
library(dplyr)
# lazyload the dataset and pass it to
iris %>%
# the ggvis function, now set the axis
ggvis(~Sepal.Width, ~Sepal.Length) %>%
# add the smoother for all points
layer_smooths(span = input_slider(0.5, 1, 0.5,
label = 'General Model'),
se = TRUE) %>%
# now group by species
group_by(Species) %>%
# add points per species and colour them
layer_points(size := input_slider(10, 200, 50,
label = 'Point Size'),
opacity := input_slider(0.5, 1, 0.5,
label = 'Point Opacity'),
fill = ~Species) %>%
# now add smoothers per species and colour them
layer_smooths(span = input_slider(0.5, 1, 0.5,
label = 'Species Models'),
fill = ~Species, se=TRUE) %>%
# add new labels
add_axis("x", title = "Sepal Width") %>%
add_axis("y", title = "Sepal Length") %>%
# finally declare as shiny object
bind_shiny("ggvis", "ggvis_ui")
```