load("Students.RData")
data
           Transport Score Brotherhood       Time
1   Public_Transport     F           3 81.2038642
2                Car     F           4  3.5746976
3   Public_Transport     C           3 51.2451380
4   Public_Transport     D           1  1.3638041
5               Bike     D           0  5.9409247
6   Public_Transport     F           4 45.1287821
7   Public_Transport     A           5  4.5104657
8   Public_Transport     C           2 30.8991132
9                Car     D           4 20.4863186
10  Public_Transport     A           4 14.2022303
11               Car     D           1 23.9651770
12  Public_Transport     D           2 16.3412274
13              Walk     F           2  5.5865170
14         Motorbike     C           2 17.5496064
15  Public_Transport     C           5 14.1716461
16               Car     C           2 24.0544996
17               Car     B           4  6.1962879
18               Car     D           2  3.0405011
19  Public_Transport     B           3 13.6939374
20               Car     C           3  4.9998038
21              Walk     D           2  5.5519060
22  Public_Transport     B           1 16.0945605
23  Public_Transport     B           1  0.4049663
24              Bike     B           2 16.3770644
25  Public_Transport     B           3 41.2585527
26               Car     C           1 75.5343450
27               Car     D           3  9.8758428
28              Bike     D           0 10.5529059
29               Car     D           2 29.5981719
30              Bike     C           1 14.7633491
31              Walk     C           3  0.5958972
32  Public_Transport     F           3  6.9081739
33  Public_Transport     D           2  5.6548999
34              Bike     C           3 76.0831409
35         Motorbike     A           4 20.9973650
36               Car     D           2  0.7479226
37  Public_Transport     C           2  5.9238454
38               Car     C           2 55.4974577
39               Car     D           2 35.0391657
40               Car     B           3  1.0689223
41               Car     C           3 41.1569394
42              Bike     C           4 38.1589737
43              Bike     B           2  7.2634336
44  Public_Transport     D           4  7.0736842
45  Public_Transport     D           0  6.3442236
46               Car     B           4 28.2376303
47               Car     F           2 14.9208720
48  Public_Transport     C           1 19.9026766
49               Car     B           2  2.8461171
50  Public_Transport     F           5 90.7599587
51  Public_Transport     D           2  0.4149180
52               Car     D           5  9.2887277
53               Car     F           0 42.5346075
54  Public_Transport     D           1  4.0768993
55  Public_Transport     B           1 14.8170098
56  Public_Transport     C           2 40.0210542
57               Car     F           3 16.5860951
58  Public_Transport     B           4  2.5801303
59  Public_Transport     C           2 22.6003957
60               Car     B           1 19.6900456
61               Car     B           2 42.3684211
62               Car     C           3 11.3303147
63  Public_Transport     C           1 33.2234480
64               Car     A           1 12.6914734
65              Walk     C           1 23.7157087
66              Walk     A           3  8.8532408
67               Car     C           2 37.7323818
68               Car     F           1 15.5325145
69               Car     C           1 48.0196141
70  Public_Transport     C           4 18.7426055
71              Walk     D           2 28.8152395
72  Public_Transport     B           0  8.0129327
73  Public_Transport     A           4 78.1471800
74               Car     D           0  1.1424262
75  Public_Transport     B           2  8.7399205
76  Public_Transport     B           3 19.5185059
77  Public_Transport     C           4  0.6533081
78               Car     C           1  9.8899481
79  Public_Transport     D           4  8.3409416
80  Public_Transport     D           4 13.7515735
81  Public_Transport     B           1 22.4699005
82  Public_Transport     F           3 43.6826990
83               Car     C           1 12.2099334
84  Public_Transport     C           2  0.2753652
85  Public_Transport     D           2  7.8281282
86               Car     B           2  5.5432996
87              Bike     A           2  3.1448994
88              Bike     C           4 42.8764015
89  Public_Transport     C           2  3.3911688
90  Public_Transport     D           3 38.8366974
91               Car     D           5 46.6558061
92               Car     C           2  4.4942830
93               Car     B           1 10.2924864
94               Car     B           0  0.4485110
95  Public_Transport     C           3 10.2044983
96              Walk     D           0  8.5508167
97  Public_Transport     C           2  2.7529707
98               Car     F           3 53.8873705
99         Motorbike     D           2  7.6115399
100             Bike     F           3 33.1478722
head(data)
         Transport Score Brotherhood      Time
1 Public_Transport     F           3 81.203864
2              Car     F           4  3.574698
3 Public_Transport     C           3 51.245138
4 Public_Transport     D           1  1.363804
5             Bike     D           0  5.940925
6 Public_Transport     F           4 45.128782
attach(data)

Qualitative data

Nominal

x=Transport
(moda=sort(unique(x)))
[1] "Bike"             "Car"              "Motorbike"        "Public_Transport"
[5] "Walk"            
(e=table(x))
x
            Bike              Car        Motorbike Public_Transport 
              10               37                3               43 
            Walk 
               7 
(n=length(x))
[1] 100
n=sum(e)
(f=e/n)
x
            Bike              Car        Motorbike Public_Transport 
            0.10             0.37             0.03             0.43 
            Walk 
            0.07 
pie(f)

barplot(f)

Ordinal

x=Score
(moda=sort(unique(x),dec=T))
[1] "F" "D" "C" "B" "A"
(e=rev(table(x)))
x
 F  D  C  B  A 
13 27 32 21  7 
(n=length(x))
[1] 100
n=sum(e)
(f=e/n)
x
   F    D    C    B    A 
0.13 0.27 0.32 0.21 0.07 
pie(f)

barplot(f)

(Fc=cumsum(f))
   F    D    C    B    A 
0.13 0.40 0.72 0.93 1.00 
barplot(Fc)

x_num=as.numeric(replace(x, x  %in%  moda, 0:4) )
boxplot(x_num)

Quantative data

Discrete

x=Brotherhood
(moda=sort(unique(x)))
[1] 0 1 2 3 4 5
(e=table(x))
x
 0  1  2  3  4  5 
 8 19 32 20 16  5 
(n=length(x))
[1] 100
n=sum(e)
(f=e/n)
x
   0    1    2    3    4    5 
0.08 0.19 0.32 0.20 0.16 0.05 
plot(moda,f,type='h')

(Fc=cumsum(f))
   0    1    2    3    4    5 
0.08 0.27 0.59 0.79 0.95 1.00 
tau=1
plot(c(min(moda)-tau,moda,max(moda)+tau),c(0,Fc,1),type='s')

mean(x)
[1] 2.32
var(x)
[1] 1.714747
sd(x)
[1] 1.309484
summary(x)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.00    1.00    2.00    2.32    3.00    5.00 
quantile(x)
  0%  25%  50%  75% 100% 
   0    1    2    3    5 
boxplot(x)

Quantative data

Continuous

x=Time
(moda=sort(unique(x)))
  [1]  0.2753652  0.4049663  0.4149180  0.4485110  0.5958972  0.6533081
  [7]  0.7479226  1.0689223  1.1424262  1.3638041  2.5801303  2.7529707
 [13]  2.8461171  3.0405011  3.1448994  3.3911688  3.5746976  4.0768993
 [19]  4.4942830  4.5104657  4.9998038  5.5432996  5.5519060  5.5865170
 [25]  5.6548999  5.9238454  5.9409247  6.1962879  6.3442236  6.9081739
 [31]  7.0736842  7.2634336  7.6115399  7.8281282  8.0129327  8.3409416
 [37]  8.5508167  8.7399205  8.8532408  9.2887277  9.8758428  9.8899481
 [43] 10.2044983 10.2924864 10.5529059 11.3303147 12.2099334 12.6914734
 [49] 13.6939374 13.7515735 14.1716461 14.2022303 14.7633491 14.8170098
 [55] 14.9208720 15.5325145 16.0945605 16.3412274 16.3770644 16.5860951
 [61] 17.5496064 18.7426055 19.5185059 19.6900456 19.9026766 20.4863186
 [67] 20.9973650 22.4699005 22.6003957 23.7157087 23.9651770 24.0544996
 [73] 28.2376303 28.8152395 29.5981719 30.8991132 33.1478722 33.2234480
 [79] 35.0391657 37.7323818 38.1589737 38.8366974 40.0210542 41.1569394
 [85] 41.2585527 42.3684211 42.5346075 42.8764015 43.6826990 45.1287821
 [91] 46.6558061 48.0196141 51.2451380 53.8873705 55.4974577 75.5343450
 [97] 76.0831409 78.1471800 81.2038642 90.7599587
(e=table(x))
x
0.275365175679326 0.404966278001666 0.414918037139569 0.448510966753875 
                1                 1                 1                 1 
 0.59589723298139 0.653308119159192 0.747922583017498  1.06892227288336 
                1                 1                 1                 1 
 1.14242617785931  1.36380407214165  2.58013027580455  2.75297067093056 
                1                 1                 1                 1 
 2.84611705863895  3.04050113681577  3.14489944884554  3.39116879263317 
                1                 1                 1                 1 
 3.57469761604443  4.07689926726744  4.49428303353488  4.51046571601182 
                1                 1                 1                 1 
 4.99980376884604  5.54329959955066  5.55190597940236  5.58651701593772 
                1                 1                 1                 1 
   5.654899911955  5.92384540426341  5.94092472602951  6.19628791045398 
                1                 1                 1                 1 
 6.34422363684418  6.90817394199961   7.0736842234619  7.26343355700374 
                1                 1                 1                 1 
 7.61153993150219  7.82812819648371  8.01293269125745  8.34094155697728 
                1                 1                 1                 1 
 8.55081665236503  8.73992045596242   8.8532408173196  9.28872770676389 
                1                 1                 1                 1 
 9.87584280781448   9.8899481180124  10.2044982714579  10.2924863896333 
                1                 1                 1                 1 
 10.5529058668762   11.330314733088  12.2099333798822  12.6914733713939 
                1                 1                 1                 1 
 13.6939374154743  13.7515735320302  14.1716461034801  14.2022303298425 
                1                 1                 1                 1 
 14.7633491179284  14.8170097612059  14.9208719928127  15.5325145481463 
                1                 1                 1                 1 
 16.0945604591491  16.3412274479499  16.3770644340973  16.5860950650956 
                1                 1                 1                 1 
 17.5496063687204  18.7426054600935  19.5185058651872  19.6900456391584 
                1                 1                 1                 1 
 19.9026765769657  20.4863185614657  20.9973649980989  22.4699005049031 
                1                 1                 1                 1 
 22.6003957150813  23.7157087162032  23.9651770475004  24.0544995513007 
                1                 1                 1                 1 
 28.2376303107915  28.8152395174525  29.5981718580646  30.8991131526105 
                1                 1                 1                 1 
 33.1478721634172  33.2234479932428  35.0391657356791   37.732381836415 
                1                 1                 1                 1 
  38.158973651602  38.8366974142376  40.0210542382241  41.1569394103352 
                1                 1                 1                 1 
 41.2585526851002  42.3684210699979  42.5346074958328  42.8764014762253 
                1                 1                 1                 1 
 43.6826990041977  45.1287821267727  46.6558060606006   48.019614090149 
                1                 1                 1                 1 
 51.2451380164667   53.887370515934  55.4974576653286  75.5343449557191 
                1                 1                 1                 1 
  76.083140894211  78.1471800053484  81.2038641715414  90.7599586962091 
                1                 1                 1                 1 
(n=length(x))
[1] 100
n=sum(e)
(f=e/n)
x
0.275365175679326 0.404966278001666 0.414918037139569 0.448510966753875 
             0.01              0.01              0.01              0.01 
 0.59589723298139 0.653308119159192 0.747922583017498  1.06892227288336 
             0.01              0.01              0.01              0.01 
 1.14242617785931  1.36380407214165  2.58013027580455  2.75297067093056 
             0.01              0.01              0.01              0.01 
 2.84611705863895  3.04050113681577  3.14489944884554  3.39116879263317 
             0.01              0.01              0.01              0.01 
 3.57469761604443  4.07689926726744  4.49428303353488  4.51046571601182 
             0.01              0.01              0.01              0.01 
 4.99980376884604  5.54329959955066  5.55190597940236  5.58651701593772 
             0.01              0.01              0.01              0.01 
   5.654899911955  5.92384540426341  5.94092472602951  6.19628791045398 
             0.01              0.01              0.01              0.01 
 6.34422363684418  6.90817394199961   7.0736842234619  7.26343355700374 
             0.01              0.01              0.01              0.01 
 7.61153993150219  7.82812819648371  8.01293269125745  8.34094155697728 
             0.01              0.01              0.01              0.01 
 8.55081665236503  8.73992045596242   8.8532408173196  9.28872770676389 
             0.01              0.01              0.01              0.01 
 9.87584280781448   9.8899481180124  10.2044982714579  10.2924863896333 
             0.01              0.01              0.01              0.01 
 10.5529058668762   11.330314733088  12.2099333798822  12.6914733713939 
             0.01              0.01              0.01              0.01 
 13.6939374154743  13.7515735320302  14.1716461034801  14.2022303298425 
             0.01              0.01              0.01              0.01 
 14.7633491179284  14.8170097612059  14.9208719928127  15.5325145481463 
             0.01              0.01              0.01              0.01 
 16.0945604591491  16.3412274479499  16.3770644340973  16.5860950650956 
             0.01              0.01              0.01              0.01 
 17.5496063687204  18.7426054600935  19.5185058651872  19.6900456391584 
             0.01              0.01              0.01              0.01 
 19.9026765769657  20.4863185614657  20.9973649980989  22.4699005049031 
             0.01              0.01              0.01              0.01 
 22.6003957150813  23.7157087162032  23.9651770475004  24.0544995513007 
             0.01              0.01              0.01              0.01 
 28.2376303107915  28.8152395174525  29.5981718580646  30.8991131526105 
             0.01              0.01              0.01              0.01 
 33.1478721634172  33.2234479932428  35.0391657356791   37.732381836415 
             0.01              0.01              0.01              0.01 
  38.158973651602  38.8366974142376  40.0210542382241  41.1569394103352 
             0.01              0.01              0.01              0.01 
 41.2585526851002  42.3684210699979  42.5346074958328  42.8764014762253 
             0.01              0.01              0.01              0.01 
 43.6826990041977  45.1287821267727  46.6558060606006   48.019614090149 
             0.01              0.01              0.01              0.01 
 51.2451380164667   53.887370515934  55.4974576653286  75.5343449557191 
             0.01              0.01              0.01              0.01 
  76.083140894211  78.1471800053484  81.2038641715414  90.7599586962091 
             0.01              0.01              0.01              0.01 
plot(moda,f,type='h')

hist(x)

hist(x,freq=F)
hist(x,freq=F,nclass=12)

hist(x,freq=F,breaks=quantile(x,seq(0,1,len=8)))

(Fc=cumsum(f))
0.275365175679326 0.404966278001666 0.414918037139569 0.448510966753875 
             0.01              0.02              0.03              0.04 
 0.59589723298139 0.653308119159192 0.747922583017498  1.06892227288336 
             0.05              0.06              0.07              0.08 
 1.14242617785931  1.36380407214165  2.58013027580455  2.75297067093056 
             0.09              0.10              0.11              0.12 
 2.84611705863895  3.04050113681577  3.14489944884554  3.39116879263317 
             0.13              0.14              0.15              0.16 
 3.57469761604443  4.07689926726744  4.49428303353488  4.51046571601182 
             0.17              0.18              0.19              0.20 
 4.99980376884604  5.54329959955066  5.55190597940236  5.58651701593772 
             0.21              0.22              0.23              0.24 
   5.654899911955  5.92384540426341  5.94092472602951  6.19628791045398 
             0.25              0.26              0.27              0.28 
 6.34422363684418  6.90817394199961   7.0736842234619  7.26343355700374 
             0.29              0.30              0.31              0.32 
 7.61153993150219  7.82812819648371  8.01293269125745  8.34094155697728 
             0.33              0.34              0.35              0.36 
 8.55081665236503  8.73992045596242   8.8532408173196  9.28872770676389 
             0.37              0.38              0.39              0.40 
 9.87584280781448   9.8899481180124  10.2044982714579  10.2924863896333 
             0.41              0.42              0.43              0.44 
 10.5529058668762   11.330314733088  12.2099333798822  12.6914733713939 
             0.45              0.46              0.47              0.48 
 13.6939374154743  13.7515735320302  14.1716461034801  14.2022303298425 
             0.49              0.50              0.51              0.52 
 14.7633491179284  14.8170097612059  14.9208719928127  15.5325145481463 
             0.53              0.54              0.55              0.56 
 16.0945604591491  16.3412274479499  16.3770644340973  16.5860950650956 
             0.57              0.58              0.59              0.60 
 17.5496063687204  18.7426054600935  19.5185058651872  19.6900456391584 
             0.61              0.62              0.63              0.64 
 19.9026765769657  20.4863185614657  20.9973649980989  22.4699005049031 
             0.65              0.66              0.67              0.68 
 22.6003957150813  23.7157087162032  23.9651770475004  24.0544995513007 
             0.69              0.70              0.71              0.72 
 28.2376303107915  28.8152395174525  29.5981718580646  30.8991131526105 
             0.73              0.74              0.75              0.76 
 33.1478721634172  33.2234479932428  35.0391657356791   37.732381836415 
             0.77              0.78              0.79              0.80 
  38.158973651602  38.8366974142376  40.0210542382241  41.1569394103352 
             0.81              0.82              0.83              0.84 
 41.2585526851002  42.3684210699979  42.5346074958328  42.8764014762253 
             0.85              0.86              0.87              0.88 
 43.6826990041977  45.1287821267727  46.6558060606006   48.019614090149 
             0.89              0.90              0.91              0.92 
 51.2451380164667   53.887370515934  55.4974576653286  75.5343449557191 
             0.93              0.94              0.95              0.96 
  76.083140894211  78.1471800053484  81.2038641715414  90.7599586962091 
             0.97              0.98              0.99              1.00 
tau=1
plot(c(min(moda)-tau,moda,max(moda)+tau),c(0,Fc,1),type='s')

mean(x)
[1] 20.33484
var(x)
[1] 405.0834
sd(x)
[1] 20.12668
summary(x)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 0.2754  5.8566 13.9616 20.3348 29.9234 90.7600 
quantile(x)
        0%        25%        50%        75%       100% 
 0.2753652  5.8566090 13.9616098 29.9234072 90.7599587 
boxplot(x)