📜  在 - R 编程语言代码示例中舍入多个列

📅  最后修改于: 2022-03-11 14:51:58.808000             🧑  作者: Mango

代码示例1
# load dplyr
library(dplyr)

# Round at first decimal with a mixed df
mydf %>% mutate(across(where(is.numeric), round, 1))

# The two solutions above do the same
mydf %>% mutate(across(where(is.numeric), ~round(., 1)))
mydf %>% mutate_if(is.numeric, round, 1)