[R] DescTools

반응형

 

1. DescTools 패키지

  • 탐색적 데이터 분석에 유용한 패키지 중 하나로 변수와 관련된 기술통계량 및 간단한 그래프를 보기 위한 유용한 패키지 입니다.
  • library(DescTools)

2. Desc() function

  • Desc() 함수 하나면 각 변수들의 기초통계량을 구할 수 있습니다.
    Desc(mtcars, plotit = TRUE)
    ## ------------------------------------------------------------------------- 
    ## Describe mtcars (data.frame):
    ## 
    ## data.frame:  32 obs. of  11 variables
    ## 
    ##   Nr  ColName  Class    NAs  Levels
    ##   1   mpg      numeric  .          
    ##   2   cyl      numeric  .          
    ##   3   disp     numeric  .          
    ##   4   hp       numeric  .          
    ##   5   drat     numeric  .          
    ##   6   wt       numeric  .          
    ##   7   qsec     numeric  .          
    ##   8   vs       numeric  .          
    ##   9   am       numeric  .          
    ##   10  gear     numeric  .          
    ##   11  carb     numeric  .          
    ## 
    ## 
    ## ------------------------------------------------------------------------- 
    ## 1 - mpg (numeric)
    ## 
    ##   length       n     NAs  unique      0s    mean  meanCI
    ##       32      32       0      25       0  20.091  17.918
    ##           100.0%    0.0%            0.0%          22.264
    ##                                                         
    ##      .05     .10     .25  median     .75     .90     .95
    ##   11.995  14.340  15.425  19.200  22.800  30.090  31.300
    ##                                                         
    ##    range      sd   vcoef     mad     IQR    skew    kurt
    ##   23.500   6.027   0.300   5.411   7.375   0.611  -0.373
    ##                                                         
    ## lowest : 10.4 (2), 13.3, 14.3, 14.7, 15.0
    ## highest: 26.0, 27.3, 30.4 (2), 32.4, 33.9
  • ## ------------------------------------------------------------------------- ## 11 - carb (numeric) ## ## length n NAs unique 0s mean meanCI ## 32 32 0 6 0 2.81 2.23 ## 100.0% 0.0% 0.0% 3.39 ## ## .05 .10 .25 median .75 .90 .95 ## 1.00 1.00 2.00 2.00 4.00 4.00 4.90 ## ## range sd vcoef mad IQR skew kurt ## 7.00 1.62 0.57 1.48 2.00 1.05 1.26 ## ## ## level freq perc cumfreq cumperc ## 1 1 7 21.9% 7 21.9% ## 2 2 10 31.2% 17 53.1% ## 3 3 3 9.4% 20 62.5% ## 4 4 10 31.2% 30 93.8% ## 5 6 1 3.1% 31 96.9% ## 6 8 1 3.1% 32 100.0%
  • ## ------------------------------------------------------------------------- ## 10 - gear (numeric) ## ## length n NAs unique 0s mean meanCI ## 32 32 0 3 0 3.69 3.42 ## 100.0% 0.0% 0.0% 3.95 ## ## .05 .10 .25 median .75 .90 .95 ## 3.00 3.00 3.00 4.00 4.00 5.00 5.00 ## ## range sd vcoef mad IQR skew kurt ## 2.00 0.74 0.20 1.48 1.00 0.53 -1.07 ## ## ## level freq perc cumfreq cumperc ## 1 3 15 46.9% 15 46.9% ## 2 4 12 37.5% 27 84.4% ## 3 5 5 15.6% 32 100.0%
  • ## ------------------------------------------------------------------------- ## 9 - am (numeric) ## ## length n NAs unique 0s mean meanCI ## 32 32 0 2 19 0.41 0.23 ## 100.0% 0.0% 59.4% 0.59 ## ## .05 .10 .25 median .75 .90 .95 ## 0.00 0.00 0.00 0.00 1.00 1.00 1.00 ## ## range sd vcoef mad IQR skew kurt ## 1.00 0.50 1.23 0.00 1.00 0.36 -1.92 ## ## ## level freq perc cumfreq cumperc ## 1 0 19 59.4% 19 59.4% ## 2 1 13 40.6% 32 100.0%
  • ## ------------------------------------------------------------------------- ## 8 - vs (numeric) ## ## length n NAs unique 0s mean meanCI ## 32 32 0 2 18 0.44 0.26 ## 100.0% 0.0% 56.2% 0.62 ## ## .05 .10 .25 median .75 .90 .95 ## 0.00 0.00 0.00 0.00 1.00 1.00 1.00 ## ## range sd vcoef mad IQR skew kurt ## 1.00 0.50 1.15 0.00 1.00 0.24 -2.00 ## ## ## level freq perc cumfreq cumperc ## 1 0 18 56.2% 18 56.2% ## 2 1 14 43.8% 32 100.0%
  • ## ------------------------------------------------------------------------- ## 7 - qsec (numeric) ## ## length n NAs unique 0s mean meanCI ## 32 32 0 30 0 17.8488 17.2045 ## 100.0% 0.0% 0.0% 18.4930 ## ## .05 .10 .25 median .75 .90 .95 ## 15.0455 15.5340 16.8925 17.7100 18.9000 19.9900 20.1045 ## ## range sd vcoef mad IQR skew kurt ## 8.4000 1.7869 0.1001 1.4159 2.0075 0.3690 0.3351 ## ## lowest : 14.5, 14.6, 15.41, 15.5, 15.84 ## highest: 19.9, 20.0, 20.01, 20.22, 22.9
  • ## ------------------------------------------------------------------------- ## 6 - wt (numeric) ## ## length n NAs unique 0s mean meanCI ## 32 32 0 29 0 3.21725 2.86448 ## 100.0% 0.0% 0.0% 3.57002 ## ## .05 .10 .25 median .75 .90 .95 ## 1.73600 1.95550 2.58125 3.32500 3.61000 4.04750 5.29275 ## ## range sd vcoef mad IQR skew kurt ## 3.91100 0.97846 0.30413 0.76725 1.02875 0.42315 -0.02271 ## ## lowest : 1.513, 1.615, 1.835, 1.935, 2.14 ## highest: 3.845, 4.07, 5.25, 5.345, 5.424
  • ## ------------------------------------------------------------------------- ## 5 - drat (numeric) ## ## length n NAs unique 0s mean meanCI ## 32 32 0 22 0 3.5966 3.4038 ## 100.0% 0.0% 0.0% 3.7893 ## ## .05 .10 .25 median .75 .90 .95 ## 2.8535 3.0070 3.0800 3.6950 3.9200 4.2090 4.3145 ## ## range sd vcoef mad IQR skew kurt ## 2.1700 0.5347 0.1487 0.7042 0.8400 0.2659 -0.7147 ## ## lowest : 2.76 (2), 2.93, 3.0, 3.07 (3), 3.08 (2) ## highest: 4.08 (2), 4.11, 4.22 (2), 4.43, 4.93
  • ## ------------------------------------------------------------------------- ## 4 - hp (numeric) ## ## length n NAs unique 0s mean meanCI ## 32 32 0 22 0 146.69 121.97 ## 100.0% 0.0% 0.0% 171.41 ## ## .05 .10 .25 median .75 .90 .95 ## 63.65 66.00 96.50 123.00 180.00 243.50 253.55 ## ## range sd vcoef mad IQR skew kurt ## 283.00 68.56 0.47 77.10 83.50 0.73 -0.14 ## ## lowest : 52.0, 62.0, 65.0, 66.0 (2), 91.0 ## highest: 215.0, 230.0, 245.0 (2), 264.0, 335.0
  • ## ------------------------------------------------------------------------- ## 3 - disp (numeric) ## ## length n NAs unique 0s mean meanCI ## 32 32 0 27 0 230.722 186.037 ## 100.0% 0.0% 0.0% 275.407 ## ## .05 .10 .25 median .75 .90 .95 ## 77.350 80.610 120.825 196.300 326.000 396.000 449.000 ## ## range sd vcoef mad IQR skew kurt ## 400.900 123.939 0.537 140.476 205.175 0.382 -1.207 ## ## lowest : 71.1, 75.7, 78.7, 79.0, 95.1 ## highest: 360.0 (2), 400.0, 440.0, 460.0, 472.0
  • ## ------------------------------------------------------------------------- ## 2 - cyl (numeric) ## ## length n NAs unique 0s mean meanCI ## 32 32 0 3 0 6.19 5.54 ## 100.0% 0.0% 0.0% 6.83 ## ## .05 .10 .25 median .75 .90 .95 ## 4.00 4.00 4.00 6.00 8.00 8.00 8.00 ## ## range sd vcoef mad IQR skew kurt ## 4.00 1.79 0.29 2.97 4.00 -0.17 -1.76 ## ## ## level freq perc cumfreq cumperc ## 1 4 11 34.4% 11 34.4% ## 2 6 7 21.9% 18 56.2% ## 3 8 14 43.8% 32 100.0%
  • Desc(data, plotit = TRUE)
  • 또한 formula 형식으로도 input을 설정할 수 있습니다.
    ## ------------------------------------------------------------------------- 
    ## mpg ~ disp
    ## 
    ## Summary: 
    ## n pairs: 32, valid: 32 (100.0%), missings: 0 (0.0%)
    ## 
    ## 
    ## Pearson corr. : -0.848
    ## Spearman corr.: -0.909
    ## Kendall corr. : -0.768
  • ## ------------------------------------------------------------------------- ## mpg ~ hp ## ## Summary: ## n pairs: 32, valid: 32 (100.0%), missings: 0 (0.0%) ## ## ## Pearson corr. : -0.776 ## Spearman corr.: -0.895 ## Kendall corr. : -0.743
  • Desc(mpg ~ disp + hp, data = mtcars)

반응형

'Basic' 카테고리의 다른 글

[R] apply 계열 함수  (0) 2017.10.06
[R] ggplot2 활용 데이터 시각화 예시  (0) 2017.08.17
[R] 문자열 처리  (0) 2017.07.12
[R] 추정 및 검정  (0) 2017.07.12
[R] 상관 분석  (0) 2017.07.07
TAGS.

Comments