1회에서는 R 기본 문법, 2회에서는 R로 하는 멀티코어 병렬 프로그래밍에 대해서 간단하게 살펴
보았다. 이번 회에서는 R로 빅 데이터를 분석하는 방법을 설명할 예정이다. 일단 왜 R에서 빅 데
이터 분석이 힘든지에 대해서 간략하게 설명을 하겠고, 이를 극복해 분석하기 위해서 몇 가지 패키
지를 활용하는 방법을 소개하겠다.
마지막 연재를 마치고 원고를 공개한다. 아마 어제 오늘 월간 마이크로소프트웨어가 나왔을테니 책에서도 볼 수 있을 것이다.
참고로 예제에서 소개했던 Rhipe로 column mean 구하는 코드를 약간 최적화 시킨 코드로 변환시켜서 여기에 올려보니 관심 있으신 분들은 참고하시기 바란다.
bigmeanmap <- expression({
y <- do.call("rbind", lapply(map.values, function(r){
as.numeric(strsplit(r,",")[[1]])
}
))
nc <- ncol(y)
for(i in 1:nrow(y)){
for(j in 1:nc){
if(is.na(y[i,][j])) next
rhcollect(j, y[i,][j])
}
}
})
bigmeanreduce<-expression(
pre={
total <- 0
cnt <- 0
},
reduce={
reduces.vec <- unlist(reduce.values)
total<-sum(total,reduces.vec)
cnt <- sum(cnt, length(reduces.vec))
},
post={rhcollect(reduce.key,total/cnt)}
)
z <- rhmr(map=bigmeanmap, reduce=bigmeanreduce,
ifolder="/rhipe/airline/hl_airline.csv",
ofolder="/rhipe/airline/out2",
inout=c("text", "sequence")
)
jobid <- rhex(z, async=TRUE)