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(googledrive) | |
# authenticate yourself | |
drive_auth() | |
gdoc_to_rmd <- function(drive_id, output, verbose = TRUE, overwrite = FALSE) { | |
# get the doc | |
doc <- drive_get(as_id(drive_id)) | |
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
# set argument values by name | |
d <- rnorm(302, mean = 43.3, sd = 9.1) | |
# set them by position | |
i <- rnorm(212, 44.6, 9.2) | |
r <- rnorm(278, 45.1, 9.2) | |
# note that you do not need to put these functions inside of the c() function | |
# because they are already returning vectors. | |
# we use c now because we want to combine multiple vectors into one |
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
# read in sav file | |
noise <- haven::read_sav("http://staff.bath.ac.uk/pssiw/stats2/noisedata.sav") | |
# convert coded response to response text | |
haven::as_factor(noise) | |
# read in sav file with column labels | |
personality <- haven::read_sav("http://staff.bath.ac.uk/pssiw/stats2/personality.sav") | |
# generate a get_label f(x) via purr |
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
label_to_colname <- function(df, pattern) { | |
get_label <- purrr::attr_getter("label") | |
col_labels <- purrr::map(df, get_label) | |
col_labels[unlist(map(col_labels, is.null))] <- names(col_labels[unlist(purrr::map(col_labels, is.null))]) | |
if (missing(pattern)) { | |
names_to_replace <- rep(TRUE, ncol(df)) | |
} else { | |
names_to_replace <- stringr::str_detect(names(col_labels), pattern) |
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
theme_bari <- function() { | |
theme_minimal() + | |
theme( | |
panel.grid.major.y = element_line( | |
size = .75 | |
), | |
panel.grid = element_line(), | |
panel.border = element_rect(size = .5, fill = NA, color = "#524d4d"), | |
text = element_text(family = "HelveticaNeue-CondensedBold"), |
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
theme_bari <- function() { | |
theme_minimal() + | |
theme( | |
panel.grid.major.y = element_line( | |
size = .75 | |
), | |
panel.grid = element_line(), | |
panel.border = element_rect(size = .5, fill = NA, color = "#524d4d"), | |
text = element_text(family = "Arial Bold"), | |
plot.title = element_text(color = "#c00000", size = 24), |
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(bbcharts) | |
library(tidyverse) | |
rock <- decade_end_bb("hot-rock-songs") | |
real_rock <- c("The Black Keys", "Panic! At The Disco", "Foo Fighters", "Fall Out Boy") | |
count(rock, artist, sort = TRUE) %>% | |
filter(n >= 2) %>% | |
mutate(artist = fct_reorder(artist, n), |
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(bbcharts) | |
library(tidyverse) | |
rock <- decade_end_bb("hot-rock-songs") | |
real_rock <- c("The Black Keys", "Panic! At The Disco", "Foo Fighters", "Fall Out Boy") | |
count(rock, artist, sort = TRUE) %>% | |
filter(n >= 2) %>% | |
mutate(artist = fct_reorder(artist, n), |
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) | |
#remotes::install_github("GuangchuangYu/nCov2019") | |
cases <- nCov2019::load_nCov2019(lang = "en") | |
pluck(cases, "global") %>% | |
group_by(time) %>% | |
summarise(cases = sum(cum_confirm)) %>% |
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
--- | |
title: "colorpalette.cinema" | |
output: html_document | |
--- | |
Fetch the color palettes from [colorpalette.cinema](https://www.instagram.com/colorpalette.cinema/). | |
```{r include=FALSE} | |
library(wesanderson) | |
library(tidyverse) |