参考:case_when: A general vectorised if
Others 用 TRUE 表示,举例如下:
x <- 1:50
case_when(
x %% 35 == 0 ~ "fizz buzz",
x %% 5 == 0 ~ "fizz",
x %% 7 == 0 ~ "buzz",
TRUE ~ as.character(x)
)
标签:case,845,函数,when,vectorised,语言 From: https://www.cnblogs.com/alex-bn-lee/p/17514201.html