📜  将所有数字列转换为百分比 - R 编程语言代码示例

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

代码示例1
myfun <- function(x) {
  if(is.numeric(x)){ 
    ifelse(is.na(x), x, paste0(round(x*100L, 1), "%")) 
  } else x 
}

df1 %>% mutate_each(funs(myfun))
#   name somevariable othervariable
# 1   A1        13.4%         53.4%
# 2   A1        54.8%          
# 3   B1        36.9%         36.9%
# 4   B1                  33.3%