library(tidyverse)
library(rap)
library(glue)
#>
#> Attaching package: 'glue'
#> The following object is masked from 'package:dplyr':
#>
#> collapse
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) | |
library(zap) | |
library(broom) | |
# gapminder data for Asia only | |
gap <- gapminder %>% | |
filter(continent == "Asia") %>% | |
mutate(yr1952 = year - 1952) %>% | |
mutate(country = fct_reorder2(country, .x = year, .y = 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
# devtools::install_github("romainfrancois/zap") | |
library(dplyr) | |
#> | |
#> 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(zap) | |
trace(wap, exit = quote({ | |
print(f) | |
fm <- formals(f) | |
print(fm) | |
sepal_length <<- fm[["Sepal.Length"]] | |
print(rlang::node_car(sepal_length)) |
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, warn.conflicts = FALSE) | |
distinct2 <- function(df, predicate_incomparable, ...) { | |
predicate_incomparable <- enquo(predicate_incomparable) | |
# rows for which the predicate os true for at least one variable | |
incomparables <- filter_all(df, any_vars(!!predicate_incomparable)) | |
# rows for which the predicate is false for all variables | |
comparables <- filter_all(df, all_vars(!(!!predicate_incomparable))) |
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, warn.conflicts = FALSE) | |
library(purrr) | |
expressions <- function(vars, funs) { | |
#' make_expr("mpg", mean) | |
make_expr <- function(var, fun) { | |
expr((!!fun)(!!sym(var))) | |
} | |
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, warn.conflicts = FALSE) | |
library(purrr) | |
named_group_split <- function(...) { | |
data <- group_by(...) | |
names <- group_keys(data) %>% | |
map(as.character) %>% | |
reduce(paste, sep = "~~") | |
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(purrr) | |
library(rap) | |
library(gapminder) | |
library(dplyr, warn.conflicts = FALSE) | |
oceania <- gapminder::gapminder %>% | |
filter(continent == "Oceania") %>% | |
mutate(yr1952 = year - 1952) %>% | |
select(-continent) %>% |
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(interactive()) { | |
.__Rprofile_env__. <- new.env(parent = emptyenv()) | |
.__Rprofile_env__.[["install"]] <- pak::pkg_install | |
attach(.__Rprofile_env__.) | |
library(usethis, warn.conflicts = FALSE) | |
library(conflicted) | |
conflict_prefer("filter", "dplyr") | |
conflict_prefer("sql", "dbplyr") |
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(rtweet) | |
library(glue) | |
library(rtweet) | |
# likes <- <chr vector of accounts that liked the tweet> | |
# retweets <- <chr vector of accounts that retweeted the tweet> | |
data <- tibble( | |
user = c(likes, retweets), |