This file contains 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
#### --------------------------------------------- | |
## Edit via: RStudio > Tools > Edit Code Snippets | |
# Released under a MIT license | |
snippet fragment | |
[${1:text}]{.${2:type}} | |
snippet aside | |
[${1:text}]{.aside} | |
This file contains 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
.First <- function(){ | |
# adapted from: https://lapsedgeographer.london/2020-11/custom-r-prompt/ | |
my_prompt <- function(...) { | |
git_branch <- suppressWarnings(system("git rev-parse --abbrev-ref HEAD", | |
ignore.stderr = TRUE, intern = TRUE)) | |
if (length(git_branch) != 0) { | |
git_msg <- paste0(" @", git_branch) |
This file contains 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(gt) | |
library(gtExtras) | |
library(nflreadr) | |
raw_qbr <- nflreadr::load_espn_qbr(league = "nfl", season = 2020:2021, | |
summary_type = "weekly") | |
qbr_df <- raw_qbr %>% | |
group_by(player_id) %>% |
This file contains 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
### Create a data dictionary from any data.frame input | |
### This is what I use for TidyTuesday each week! | |
# Tidyverse method | |
create_dictionary <- function(x) { | |
tibble::tibble(variable = names(x)) %>% | |
dplyr::mutate( | |
class = purrr::map( | |
x, |
This file contains 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: "Presentation" | |
format: | |
revealjs: | |
theme: [default, custom.scss] | |
--- | |
## Slide 1 | |
- List |
This file contains 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
``` r | |
library(dplyr) | |
# vector operation | |
chunk_vec <- function(chunk_size){ | |
ceiling(seq_along(row_number())/chunk_size) | |
} | |
# operate on dataframe | |
chunk_df <- function(.data, chunk_size) { |
This file contains 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(stringr) | |
library(jsonlite) | |
# create a function to solve the Keyword game | |
# this game uses a 6 letter horizontal word at the | |
# intersection of 6 other words, where a missing letter from each of the vertical words | |
# accounts for one letter of the mystery 6 letter length horizontal word | |
# how to play |
This file contains 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(jsonlite) | |
library(shiny) | |
# get_json_data(date) | |
# score_letters(letters) | |
# read_keywords() on mac | |
# split_char(word) into words | |
# limit_words(words, str_length) to specific length and lower case | |
# top_words(word, words_in, top_n = 50) - combo of split_char, limit_words |
This file contains 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
ex_bold <- ggplot(mtcars, aes(disp, mpg)) + | |
geom_point() + | |
labs( | |
title = "<b>Fuel economy</b> vs. <i>engine displacement</i><br> | |
<span style = 'font-size:10pt'>Lorem ipsum *dolor sit amet,* | |
consectetur adipiscing elit, **sed do eiusmod tempor incididunt** ut | |
labore et dolore magna aliqua. <span style = 'color:red;'>Ut enim | |
ad minim veniam,</span> quis nostrud exercitation ullamco laboris nisi | |
ut aliquip ex ea commodo consequat.</span>", | |
x = "displacement (in<sup>3</sup>)", |
This file contains 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(jsonlite) | |
library(shiny) | |
# get_json_data(date) | |
# score_letters(letters) | |
# read_keywords() on mac | |
# split_char(word) into words | |
# limit_words(words, str_length) to specific length and lower case | |
# top_words(word, words_in, top_n = 50) - combo of split_char, limit_words |
NewerOlder