library(dplyr) # gives mutate_if
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(tidyverse) | |
library(gapminder) | |
# User Interface | |
ui <- basicPage( | |
sliderInput("year", "Select year:", animate = TRUE, | |
min = 1952, max = 2007, value = 2007, | |
step = 5, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) # gives mutate_if | |
library(forcats) # gives fct_explicit_na | |
#example dataframe, a and c are factors, | |
#b is numeric, d is boolean (TRUE/FALSE) | |
mydata = data.frame( | |
a = c( 'Yes', 'No', NA), | |
b = c( 0.5, NA, 0.6), | |
c = c( 'No', NA, 'Yes'), | |
d = c( TRUE, NA, FALSE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(gapminder) | |
library(tidyverse) | |
mydata = gapminder | |
gapminder %>% | |
filter(year == 2007) %>% | |
ggplot(aes(y = lifeExp, x = continent)) + | |
geom_boxplot() + | |
geom_jitter(aes(size = pop/1000000, fill = lifeExp), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
p = ggplot(diamonds, aes(x = color, fill=cut(price, | |
breaks = quantile(price), | |
include.lowest=TRUE, | |
labels = c('Expensive', | |
'More expensive', | |
'Very expensive', | |
'Ridiculously expensive')))) + | |
geom_bar(position='fill') + | |
facet_wrap(~cut) + |
NewerOlder