Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
78 lines (64 sloc) 2.05 KB
---
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")
```