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(tidyverse) | |
| library(hrbrthemes) | |
| # download https://github.com/rfordatascience/tidytuesday/blob/master/data/tidy_tuesday_week2.xlsx | |
| football <- read_xlsx("data/tidy_tuesday_week2.xlsx") | |
| # get the top 16 paid players in each position for each year | |
| to_plot <- football %>% | |
| mutate(Team = 1:nrow(.)) %>% | |
| gather(position, salary, -c(year, Team)) %>% |
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
| if (!require(INLA)){ | |
| install.packages("INLA", | |
| repos=c(getOption("repos"), | |
| INLA="https://inla.r-inla-download.org/R/testing"), | |
| dep=TRUE) | |
| } | |
| library(INLA) | |
| library(tidyverse) | |
| library(broom) |
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
| trim_percent <- function(x, ...){ | |
| require(magrittr) | |
| require(scales) | |
| require(stringr) | |
| scales::percent(x, ...) %>% | |
| stringr::str_replace(string = ., pattern = "0+\\%", replacement = "\\%") %>% | |
| stringr::str_replace(string = ., pattern = "\\.\\%", replacement = "\\%") | |
| } |
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(tidyverse) | |
| expand.grid(day = 1:7, week = 1:13) %>% | |
| mutate(mu = 3*sin(day*2*pi/7)) %>% | |
| mutate(p = boot::inv.logit(mu)) %>% | |
| mutate(obs = rbinom(n(), size = 1, p = p), | |
| pred = rbinom(n(), size = 1, p = p)) %>% | |
| gather(key, value, obs, pred) %>% | |
| mutate(value = factor(value)) %>% | |
| ggplot(data =., aes(x = day, y = key)) + | |
| geom_tile(aes(fill = value)) + |
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(NHANES) | |
| data(NHANES) | |
| library(tidyverse) | |
| library(extrafont) | |
| library(lme4) | |
| library(RColorBrewer) | |
| NHANES <- mutate(NHANES, | |
| SexOrientation = fct_relevel(SexOrientation, "Heterosexual"), | |
| Education = fct_relevel(Education, "High School")) |
OlderNewer