Interactive Data Visualization with plotly in R
Adam Loy
Statistician, Carleton College
glimpse(winequality)
Rows: 178
Columns: 14
$ type <chr> "red", "red", "red", "red", "red", "red", ...
$ fixed_acidity <dbl> 8.2, 8.2, 8.0, 10.2, 8.6, 6.1, 10.7, 9.1, 7.2...
$ volatile_acidity <dbl> 0.885, 0.640, 0.715, 0.360, 0.520, 0.590, 0.6...
$ citric_acid <dbl> 0.20, 0.27, 0.22, 0.64, 0.38, 0.01, 0.22, 0.3...
$ residual_sugar <dbl> 1.40, 2.00, 2.30, 2.90, 1.50, 2.10, 2.70, 2.1...
...
$ sulphates <dbl> 0.46, 0.62, 0.54, 0.66, 0.52, 0.56, 0.98, 0.8...
$ alcohol <dbl> 10.0, 9.1, 9.5, 12.5, 9.4, 11.4, 9.9, 11.2, 1...
$ quality <int> 5, 6, 6, 6, 5, 5, 6, 6, 6, 7, 6, 5, 4, 6, 6, ...
$ quality_label <chr> "low", "medium", "medium", "medium", "low", ...
winequality %>%
plot_ly(x = ~residual_sugar, y = ~fixed_acidity) %>%
add_markers()
winequality %>% count(type, quality_label) %>%
plot_ly(x = ~type, y = ~n, color = ~quality_label) %>%
add_bars() %>%
layout(barmode = "stack")
winequality %>% count(type, quality_label) %>%
group_by(type) %>%
mutate(prop = n / sum(n)) %>%
plot_ly(x = ~type, y = ~prop, color = ~quality_label) %>% add_bars() %>% layout(barmode = "stack")
group_by()
winequality %>%
plot_ly(x = ~quality_label, y = ~alcohol) %>%
add_boxplot()
Interactive Data Visualization with plotly in R