df<-data.frame(Gender = c("F", "F", "M","M","F"),
Score = c(80, 70, 65, 85, 95),
Type = c("A","B","C","B","B"))
df[sapply(df, is.character)] <- lapply(df[sapply(df, is.character)],
as.factor)
df[sapply(df, is.factor)] <- lapply(df[sapply(df, is.factor)],
as.character)
options(warn = -1) #关闭警告信息
options(warn = 0) #打开警告信息