네, 당신이 찾고있는 것이 요인 이라고 생각합니다 . 예를 들면 :
> text <- c('Kate', 'Kate', 'Larry', 'Larry', 'Marie', 'Marie', 'Marie', 'Marie')
> fact <- as.factor(text)
> fact
[1] Kate Kate Larry Larry Marie Marie Marie Marie
Levels: Kate Larry Marie
내부적으로 R은 이것을 정수 벡터로 저장합니다.
> unclass(fact)
[1] 1 1 2 2 3 3 3 3
attr(,"levels")
[1] "Kate" "Larry" "Marie"
-------------------factor
다음으로 변환 integer
:
> column <- c('Kate','Kate','Larry','Larry','Marie','Marie','Marie','Marie')
> as.integer(factor(column))
[1] 1 1 2 2 3 3 3 3
출처
https://stackoverflow.com/questions/22009826