Dummy variable 확실하게 처리하기

 더미 변수를 만들기.

#

library(fastDummies)


#샘플 데이터

fastDummies_example <- data.frame(numbers = 1:3,

                    gender  = c("male", "male", "female"),

                     animals = c("dog", "dog", "cat"),

                     dates   = as.Date(c("2012-01-01", "2011-12-31",

                                                      "2012-01-01")),

                     stringsAsFactors = FALSE)

#모든 컬럼을 근거로 더미 만들기

results <- fastDummies::dummy_cols(fastDummies_example)

#특정 컬럼 결정하기

fastDummies::dummy_cols(fastDummies_example, select_columns = "numbers")

#조합 줄이기

fastDummies::dummy_cols(fastDummies_example, remove_first_dummy = TRUE)


댓글

  1. Las Vegas Casino & Hotel Map & Floor Plans - MapYRO
    Find your way around the 대구광역 출장샵 casino, find where everything is located with a 의왕 출장안마 map showing your location and all 부산광역 출장샵 the important data needed 진주 출장마사지 to 청주 출장샵 easily

    답글삭제

댓글 쓰기

이 블로그의 인기 게시물

R에서 csv 파일 읽는 법

xlwings tutorial - 데이터 계산하여 붙여 넣기