분석작업의 용이,편리성을 위한 컬럼명 변경하기
?
컬럼명을 자유자재로 변경(긴것을 짧게, 알 수 있도록)
캐글등 영문 데이터의 컬럼명들이 대문자와 소문자가 혼재되어 있는 경우가 많다.
하나의 합성어로서 ’SatisfactionLevel’와 같은 경우인데
이것은 ’Satisfaction Level’이라는 표현으로서 단어사이 띄어쓰기가 원래 사용되어야 하지만
R에서는 띄어쓰기를 허용하지 않는다. 그래서 붙여쓰기하면서 공란뒤의 글자는 대문자로 바꿔서 입력하는 경우가 발생한다.
데이터를 읽어 왔다면 먼저 하여야 하는 것이 데이터 컬럼명이 어떻게 되어 있는가를 확인하여야 한다.
hire <- read.csv("N:/study/myhuman.csv")
names(hire)
## [1] "Sociability" "Rating" "Career" "Score" "Group"
names(hire)[1] <- "sociability"
names(hire)[1]
## [1] "sociability"
names(hire) <- c("sociability","rating","career","score","hire")
names(hire)
## [1] "sociability" "rating" "career" "score" "hire"
colnames(hire)
## [1] "sociability" "rating" "career" "score" "hire"