R에서 통계분석 데이터 이용하기 foreign 패키지 SPSS, SAS, STATA 등 통계분석 소프트웨어의 파일을 불러오기 위해서 'foreign' 패키지를 이용한다. install.packages('foreign') library(foreign) # SPSS 파일 불러오기 library(dplyr) # 전처리 library(ggplot2) # 시각화 library(readxl) # 엑셀 파일 불러오기 # SPSS 파일을 Dataframe으로 가져온다 raw_welfare <- read.spss(file = 'Koweps_hpc10_2015_beta1.sav', to.data.frame = T) # 복사본을 만든다 welfare <- raw_welfare # colume에 대한 정보 분석 str(welfare) # colume 명 변경 welfare <- rename(welfare, sex = h10_g3, birth = h10_g4, marriage = h10_g10, religion = h10_g11, income = p1002_8aq1, code_job = h10_eco9, code_region = h10_reg7 ) # 성별 항목 이름 부여 sex : 1 -> male 2 -> female > welfare$sex <- ifelse(welfare$sex == 1, 'male', 'female') > table(welfare$sex) ## female male ## 9086 7578 qplot(welfare$sex