这是设置:
mydf<-structure(list(weight = c(1.34288799762726, 1.18884372711182,
1.15979790687561, 1.34288799762726, 1.08285343647003, 1.07932889461517,
1.28913342952728, 1.211909532547, 1.03438591957092, 1.22719633579254
), RespID = c(3182, 3183, 3184, 3185, 3186, 3187, 3188, 3189,
3190, 3191), b1 = structure(c(1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L,
2L, 2L), .Label = c("Mand", "Kvinde"), class = "factor")), .Names = c("weight",
"RespID", "b1"), row.names = c(NA, 10L), class = "data.frame")
现在调用 summary 将生成以下输出:
summary(mydf)
# weight RespID b1
# Min. :1.034 Min. :3182 Mand :4
# 1st Qu.:1.102 1st Qu.:3184 Kvinde:6
# Median :1.200 Median :3186
# Mean :1.196 Mean :3186
# 3rd Qu.:1.274 3rd Qu.:3189
# Max. :1.343 Max. :3191
同时 apply 给出了另一个结果:
apply(mydf, 2, class)
# weight RespID b1
#"character" "character" "character"
所以根据应用我的data.frame中的每一列都是我知道是错误的“字符”类。总结虽然是正确的。