Created
August 26, 2023 21:58
-
-
Save angelotrivelli/38f325e3fa12f8279eca527f30525498 to your computer and use it in GitHub Desktop.
pmap is confusing
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) | |
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