Jennifer Bryan 的演讲(https://speakerdeck.com/jennybc/row-orientation-workflows-in-r-with-the-tidyverse)让我相信,我本学期的决心是完全致力于 tidyverse 方法。但是,我的第一次编码会话已经以失败告终:
# load the necessary packages
library(tidyverse)
# create examples of my data set
prob = tibble(names = letters[1:17])
sample1 = sample(letters, 5)
# tidyverse approach, does not work
pmap(sample1, function(x) prob == x)
# basic R approach, does work
lapply(sample1, function(x) prob == x)
# how can I change the pmap code to make it work?
所有在线匿名函数 pmap 示例都没有包含不同的对象(在我的例子中是“prob”),所以也许这就是问题所在?或者更有可能我在如何指定匿名函数方面遗漏了一些东西?