-
attatch활용 분석카테고리 없음 2019. 6. 9. 22:43
setwd("c:/r1")
gdp <- read.csv("gdp.csv",sep=",",header=TRUE)
View(gdp)
str(gdp)
ndemog <-read.csv("ndemog.csv",sep=",",header=TRUE)
View(ndemog)
merge = merge(ndemog,gdp) ##같은 항목은 제외하고 합ㅊ
View(merge)
##ndemog는 2017년 까지밖에 없음 그러니까 merge하면 저절로
##2018사라짐
attach(merge) ##attach함수: merge라는 변수안의 작은 변수들에 경로를 알려주는? $표시 안해줘도 된다.즉 데이터를 R 검색 경로에 추가하여 변수명으로 바로 접근할 수 있게 한다. 해제해주고 싶을땐 detach해주면 된다.
a = tapply(gdpto, tfr_c, mean)
a
b = tapply(gdppc, tfr_c, mean)
b
c = rbind(a,b)
c
row.names(c) <- c("국내총생산","1인당총생산")
c
c <-round(c,digit=0) ##소수점0부터 반올림
View(c)
plot(year,gdpto)
plot(year,gdppc)
write.csv(merge,file="merge.csv")