library(dplyr)
library(data.table)
# dplyr across ------------------------------------------------------------
iris %>%
group_by(Species) %>%
summarise(across(c(Sepal.Length, Sepal.Width), tibble::lst(mean, median)))
#> `summarise()` ungrouping output (override with `.groups` argument)
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
# scales::date_format() only relies on strptime(), which does not support | |
# quarter formatting. stringi does, but the format strings have a different | |
# syntax | |
quarter_format <- function(x, format = "yyyyqqq", tz = "UTC", locale = "en_EN") { | |
function(x) stringi::stri_datetime_format(time = x, format, tz, locale) | |
} | |
# Example, inspired by the ggplot2 docs | |
library(ggplot2) |
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(magick) | |
library(tidyverse) | |
path_heics <- dir("~/Downloads/", pattern = "HEIC$", full.names = TRUE) | |
path_jpeg <- str_replace(path_heics, "HEIC", "jpeg") | |
# convert before writing | |
heics <- map(path_heics, image_read) | |
jpeg <- map(heics, image_convert, format = "jpeg") | |
walk2(jpeg, path_jpeg, image_write, quality = 50) |
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(stringr) | |
library(sessioninfo) | |
libpath <- .libPaths()[[1]] | |
pkgs <- basename(dir(libpath)) | |
info <- package_info(pkgs) | |
github <- info %>% |
# Question from the R-Ladies Slack Channel
library(tidyverse)
test_data <- tibble::tribble(
~c1, ~c2, ~c3, ~c4,
1, 2, 2, 4,
3, 4, 3, 4,
NA_integer_, 4, 4, 3,
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
I hereby claim:
- I am mpaulacaldas on github.
- I am mpaulacaldas (https://keybase.io/mpaulacaldas) on keybase.
- I have a public key ASCvCYR-gM2TLCBMqFc-BLvw-yJxcE7jwOmNy6NT6Nii1Ao
To claim this, I am signing this object: