-
demog <- read.csv("demog.csv", sep=",", header=FALSE,stringsAsFactor=FALSE) #readfile
str(demog) #구조호
names(demog) <- c("year","cdr","tfr","marn","leo")
#이름 변경
View(demog) #확인해보니 위에 첫줄이 이상함
demog <- demog[-1,] #이상한 첫줄 제거
demog <- demog[-49,] #2018suseh 이상하니까 제거해줌
rownames(demog) #행머리글 제거
View(demog)
demog$year_n1 <- as.numeric(demog$year)
demog$cdr_n1 <- as.numeric(demog$cdr)
demog$tfr_n1 <- as.numeric(demog$tfr)
demog$marn_n1 <- as.numeric(demog$marn)
demog$leo_n1 <- as.numeric(demog$leo) #형태변환 ,이유...?
#이유:읽어오면 캐릭터형이니 수치형으로 바꾸기위해서
sdemog <- demog[,c(6,7,8,9,10)] # 필요한 부분만 추추
View(sdemog) #확인해보기
names(sdemog) <- c("year","cdr","tfr","marn","leo")
#이름변경해보기
str(sdemog) #확인해보기
##sdemog.csv로 저장하기
write.table(sdemog,file="sdemog.csv",sep=",",row.names=FALSE,col.names = TRUE)