Base R
单个变量
data$x1 <- as.numeric(as.character(data$x1))
多个变量
i <- c(2, 3)
data[ , i] <- apply(data[ , i], 2, # Specify own function within apply function(x) as.numeric(as.character(x)))
DPLYR
library(dplyr)
mtcars %>% mutate(across(everything(), as.character))
标签:类型转换,mutate,character,问题,everything,Base,x1
From: https://www.cnblogs.com/xiaosagege/p/16925363.html