Saturday, 26 November 2016

17 matrics statistics functions In R language


matrics statistics
min()
max()
range()
sd()
rowMeans()
colMeans()
apply(,2,FUN=sd)
cor()
table()
summary()
summary(t())
-----------------
> View(newdata)
> View(temp1)
> temp1
       vijayawad hyderabad delhi
Nov/12        88        62    90
Nov/13        85        61    92
Nov/14        83        54    91
Nov/15        81        60    89
Nov/16        78        65    90
> temp2
       Chennai Pune Bengalore
Nov/12      99   62        90
Nov/13      85   61        92
Nov/14      83   54        71
Nov/15      81   60        89
Nov/16      66   88        90
> ftemp
       vijayawad hyderabad delhi Chennai Pune
Nov/12        88        62    90      99   62
Nov/13        85        61    92      85   61
Nov/14        83        54    91      83   54
Nov/15        81        60    89      81   60
Nov/16        78        65    90      66   88
Nov/17        98        78    66      55   99
       Bengalore
Nov/12        90
Nov/13        92
Nov/14        71
Nov/15        89
Nov/16        90
Nov/17        66
> View(ftemp)
> min(ftemp)
[1] 54
> max(ftemp)
[1] 99
> range(ftemp)
[1] 54 99
> range(ftemp)[1]
[1] 54
> range(ftemp)[2]
[1] 99
> sd(ftemp)
[1] 14.23778
> rowMeans(ftemp)
  Nov/12   Nov/13   Nov/14   Nov/15   Nov/16
81.83333 79.33333 72.66667 76.66667 79.50000
  Nov/17
77.00000
> colMeans(ftemp)
vijayawad hyderabad     delhi   Chennai
 85.50000  63.33333  86.33333  78.16667
     Pune Bengalore
 70.66667  83.00000
> sd(ftemp)
[1] 14.23778
> apply(ftemp,2,sd)
vijayawad hyderabad     delhi   Chennai
 7.007139  8.041559 10.013324 15.471479
     Pune Bengalore
18.239152 11.384200
> apply(ftemp,1,sd)
  Nov/12   Nov/13   Nov/14   Nov/15   Nov/16
15.82930 14.54189 15.80717 13.39652 11.72604
  Nov/17
18.17691
> cor(ftemp)
           vijayawad  hyderabad      delhi
vijayawad  1.0000000  0.7347158 -0.8522797
hyderabad  0.7347158  1.0000000 -0.9007808
delhi     -0.8522797 -0.9007808  1.0000000
Chennai   -0.3219236 -0.7367826  0.7380108
Pune       0.4647732  0.9131535 -0.7723986
Bengalore -0.6242896 -0.3845032  0.7158291
             Chennai       Pune  Bengalore
vijayawad -0.3219236  0.4647732 -0.6242896
hyderabad -0.7367826  0.9131535 -0.3845032
delhi      0.7380108 -0.7723986  0.7158291
Chennai    1.0000000 -0.8679834  0.5393731
Pune      -0.8679834  1.0000000 -0.3583157
Bengalore  0.5393731 -0.3583157  1.0000000
> table(ftemp)
ftemp
54 55 60 61 62 65 66 71 78 81 83 85 88 89 90 91
 2  1  2  2  2  1  3  1  2  2  2  2  2  2  4  1
92 98 99
 2  1  2
> summary(ftemp)
   vijayawad       hyderabad         delhi    
 Min.   :78.00   Min.   :54.00   Min.   :66.00
 1st Qu.:81.50   1st Qu.:60.25   1st Qu.:89.25
 Median :84.00   Median :61.50   Median :90.00
 Mean   :85.50   Mean   :63.33   Mean   :86.33
 3rd Qu.:87.25   3rd Qu.:64.25   3rd Qu.:90.75
 Max.   :98.00   Max.   :78.00   Max.   :92.00
    Chennai           Pune         Bengalore 
 Min.   :55.00   Min.   :54.00   Min.   :66.0
 1st Qu.:69.75   1st Qu.:60.25   1st Qu.:75.5
 Median :82.00   Median :61.50   Median :89.5
 Mean   :78.17   Mean   :70.67   Mean   :83.0
 3rd Qu.:84.50   3rd Qu.:81.50   3rd Qu.:90.0
 Max.   :99.00   Max.   :99.00   Max.   :92.0
> summary(t(ftemp)
+ )
     Nov/12          Nov/13          Nov/14   
 Min.   :62.00   Min.   :61.00   Min.   :54.00
 1st Qu.:68.50   1st Qu.:67.00   1st Qu.:58.25
 Median :89.00   Median :85.00   Median :77.00
 Mean   :81.83   Mean   :79.33   Mean   :72.67
 3rd Qu.:90.00   3rd Qu.:90.25   3rd Qu.:83.00
 Max.   :99.00   Max.   :92.00   Max.   :91.00
     Nov/15          Nov/16         Nov/17
 Min.   :60.00   Min.   :65.0   Min.   :55
 1st Qu.:65.25   1st Qu.:69.0   1st Qu.:66
 Median :81.00   Median :83.0   Median :72
 Mean   :76.67   Mean   :79.5   Mean   :77
 3rd Qu.:87.00   3rd Qu.:89.5   3rd Qu.:93
 Max.   :89.00   Max.   :90.0   Max.   :99
>

No comments:

Post a Comment