Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelotrivelli/38f325e3fa12f8279eca527f30525498 to your computer and use it in GitHub Desktop.
Save angelotrivelli/38f325e3fa12f8279eca527f30525498 to your computer and use it in GitHub Desktop.
pmap is confusing
library(tidyverse)
d <- tibble(batch = c('one', 'two', 'three'),
device = c('a','b','c'),
num = c(1,2,3))
myfunc1 <- function(batch, device, num) {
return(paste0(batch, '_', device, '_', 10+num))
}
myfunc2 <- function(batch, device, num, w) {
return(paste0(batch, '_', device, '_', w + num))
}
x1 <- pmap(d, myfunc1)
x2 <- pmap(d, myfunc2, w=10)
# x1 and x2 are the same
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment