I’d like to understand why the first block works but the second does not. I believe it has something to do with the fact that pwalk
does not actually output anything. However, the error is concated_cols must be size 150 or 1, not 2
. I would have expected it to be size 1. What is it outputing?
library(tidyverse)
#pmap: Works
iris|>
mutate(concated_cols=pmap(
.l = list(Sepal.Length=Sepal.Length,Petal.Length=Petal.Length),
.f = (Sepal.Length,Petal.Length){
str_c(Sepal.Length,Petal.Length)
}
))
#pwalk: Does not work (in my use case, I was trying to use pwalk to write out files, so this is just to demo the error
iris|>
mutate(concated_cols=pwalk(
.l = list(Sepal.Length=Sepal.Length,Petal.Length=Petal.Length),
.f = (Sepal.Length,Petal.Length){
str_c(Sepal.Length,Petal.Length)
}
))