作者:黄勋佩淑青宜合 | 来源:互联网 | 2022-12-28 18:00
1> Psidom..:
使用do.call
有coalesce
:
do.call(coalesce, df)
# [1] "a" "b" "b"
do.call
将列按顺序传递df
到coalesce
,因此等效于coalesce(df$first, df$second, df$third)
。
df <- data_frame(
first = c("a", NA, "b"),
secOnd= c(NA, "b", NA),
third = c("a", NA, NA)
)