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
# original issue: https://github.com/rstudio/rstudio/issues/1941 | |
library(purrr) | |
library(cli) | |
library(dplyr) | |
# test -------------------------------------------------------------------- | |
paint <- function(txt, palette) { | |
colors <- palette(nchar(txt), alpha = 1) | |
txt <- paste( | |
map2_chr(strsplit(txt, "")[[1]], colors, ~cli::make_ansi_style(.y)(.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
romainfrancois@sherlox /tmp % brew install apache-arrow --HEAD -v | |
==> Downloading https://github.com/apache/arrow/commit/ae60bad1c2e28bd67cdaeaa05f35096ae193e43a.patch?full_index=1 | |
Already downloaded: /Users/romainfrancois/Library/Caches/Homebrew/downloads/bebaf2a7625dae0afc3e8aca8f0a05cd8f341811c2661341315d537706ac2cfc--ae60bad1c2e28bd67cdaeaa05f35096ae193e43a.patch | |
==> Verifying bebaf2a7625dae0afc3e8aca8f0a05cd8f341811c2661341315d537706ac2cfc--ae60bad1c2e28bd67cdaeaa05f35096ae193e43a.patch checksum | |
==> Cloning https://github.com/apache/arrow.git | |
Updating /Users/romainfrancois/Library/Caches/Homebrew/apache-arrow--git | |
git config remote.origin.url https://github.com/apache/arrow.git | |
git config remote.origin.fetch \+refs/heads/master:refs/remotes/origin/master | |
git config remote.origin.tagOpt --no-tags | |
git fetch origin |
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(dplyr, warn.conflicts = FALSE) | |
library(palmerpenguins) | |
# multiple rows | |
penguins %>% | |
group_by(species) %>% | |
summarise( | |
prob = c(.25, .75), | |
length = quantile(bill_length_mm, prob, na.rm = TRUE), | |
depth = quantile(bill_depth_mm, prob, na.rm = TRUE) |
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(dplyr) | |
library(purrr) | |
df <- tribble( | |
~x, ~y, | |
"a", "b", | |
"c", "b", | |
"b", "a", | |
"b", "b", | |
"a", "a" |
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
suppressMessages(library(tidyverse)) | |
musique <- jsonlite::read_json("https://www.data.gouv.fr/fr/datasets/r/0dba0390-5eba-401f-aae5-933243c0b163", simplifyDataFrame = TRUE)$fields | |
musique %>% | |
pull("keywords_fr") %>% | |
str_split(";") %>% | |
flatten_chr() %>% | |
table() %>% | |
enframe() %>% |
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(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), |
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
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 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 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 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))) | |
} | |
NewerOlder