'mutate' to add two columns with a single fn-call in tidyverse in R
问题 This is an R Version 3.4.4 question A voting function voteOnBase , takes 2 arguments and returns a 2-element list: the WINNER and the VOTE.COUNT . I want to use it to add those two columns to notVotedYet , a tibble. The following code runs correctly. library(tidyverse) withVotes <- notVotedYet %>% group_by(BASE) %>% mutate(WINNER = voteOnBase(BASE, CODES)[[1]], VOTE.COUNT = voteOnBase(BASE, CODES)[[2]]) However, it calls voteOnBase twice on the same inputs. How can I eliminate the extra