setwd("C:/DSI_Data_HW3")
beach <- read.csv("HW3_Beachtown.csv")
head(beach, 46)
str(beach)
table(beach$SPEOPLE)
summary(beach)
beach_z <- as.data.frame(lapply(beach, scale))
答案 0 :(得分:3)
正如Roland所指出的那样,你无法对分类变量进行缩放...在你的情况下,将data.frame
子集化为具有数值的列会有所帮助。
beach_z <- as.data.frame(apply(beach[c('SPEOPLE','SCAR')], scale))
# or maybe easier...
beach_z <- scale(beach[c('SPEOPLE','SCAR')])