Statistical Analytics

Sample Code


사용할 데이터는 Revolution 폴더안의 Sample Data로, "mortDefaultSmall2009"라는 이름의 csv파일이다.
데이터의 행 수는 총 10000개 이고, 'creditScore', 'houseAge', 'yearsEmploy', 'ccDebt', 'year', 'default' 로 총 6개의 변수(열)를 가지고 있다.
현재 사용한 데이터는 2009년 데이터이지만, 실제는 2000년부터 2009년까지 10년간의 sample data가 있다.
뒤에 데이터 합치기와 같은 부분에서 다른 연도의 데이터도 사용될 것이다.

# (1-1)data의 위치지정 Revolution R을 다운할 시, 자동으로 생성되는 Sample
# data중 하나인 데이터로, sampleData폴더의 'mortDefaultSmall2009'
# csv파일을 사용

text_mort <- "C:/Revolution/R-Enterprise-6.1/R-2.14.2/library/RevoScaleR/SampleData/mortDefaultSmall2009.csv"


# (1-2)rxImport를 사용한 data import

data_mort <- rxImport(inData = text_mort, outFile = "data_mort.xdf", overwrite = TRUE)
# (1-3)rxHistogram 을 사용하여 히스토그램 그리기 전체 데이터를 기준으로
# 하여, x축에 'creditScore'변수를 넣고 히스토그램을 그리도록 하였다.
# title argument를 사용하여 'rxHistogram'이라는 제목을 갖는 그림을 그렸고,
# lineColor는 black으로 지정해주어, 각 bar들의 외곽선의 색상을 검정색으로
# 설정해 주었다. 또한 , fillColor를 red로 설정해 각 bar의 색상이 빨강색이
# 되도록 지정해주었다.

rxHistogram(~creditScore, data = data_mort, title = "rxHistogram 예제", lineColor = "black", 
    fillColor = "red")
## Rows Read: 10000, Total Rows Processed: 10000, Total Chunk Time: 0.010 seconds 
## Computation time: 0.020 seconds.

plot of chunk unnamed-chunk-2

Appendix

rxHistogram

Usage

rxHistogram(formula, data, pweights = NULL, fweights = NULL, numBreaks = NULL,
startVal = NULL, endVal = NULL, levelsToDrop = NULL,
levelsToKeep = NULL, rowSelection = NULL, transforms = NULL,
transformObjects = NULL, transformFunc = NULL, transformVars = NULL,
transformPackages = NULL, transformEnvir = NULL,
blocksPerRead = rxGetOption(“blocksPerRead”),
histType = “Counts”,
title = NULL, subtitle = NULL, xTitle = NULL, yTitle = NULL,
xNumTicks = NULL, yNumTicks = NULL, xAxisMinMax = NULL,
yAxisMinMax = NULL, fillColor = “cyan”, lineColor = “black”,
lineStyle = “solid”, lineWidth = 1, plotAreaColor = “gray90”,
gridColor = “white”, gridLineWidth = 1, gridLineStyle = “solid”,
maxNumPanels = 100, reportProgress = rxGetOption(“reportProgress”),
print = TRUE, …)


Hankuk University of Foreign Studies. Dept of Statistics. Daewoo Choi Lab. Yeeseul Han.
한국외국어대학교 통계학과 최대우 연구실 한이슬
e-mail : han.lolove17@gmail.com