pol

Author

dol

df <- read.csv("~/Downloads/train.csv")

head(df)
  PassengerId Survived Pclass
1           1        0      3
2           2        1      1
3           3        1      3
4           4        1      1
5           5        0      3
6           6        0      3
                                                 Name    Sex Age SibSp Parch
1                             Braund, Mr. Owen Harris   male  22     1     0
2 Cumings, Mrs. John Bradley (Florence Briggs Thayer) female  38     1     0
3                              Heikkinen, Miss. Laina female  26     0     0
4        Futrelle, Mrs. Jacques Heath (Lily May Peel) female  35     1     0
5                            Allen, Mr. William Henry   male  35     0     0
6                                    Moran, Mr. James   male  NA     0     0
            Ticket    Fare Cabin Embarked
1        A/5 21171  7.2500              S
2         PC 17599 71.2833   C85        C
3 STON/O2. 3101282  7.9250              S
4           113803 53.1000  C123        S
5           373450  8.0500              S
6           330877  8.4583              Q
tail(df)
    PassengerId Survived Pclass                                     Name    Sex
886         886        0      3     Rice, Mrs. William (Margaret Norton) female
887         887        0      2                    Montvila, Rev. Juozas   male
888         888        1      1             Graham, Miss. Margaret Edith female
889         889        0      3 Johnston, Miss. Catherine Helen "Carrie" female
890         890        1      1                    Behr, Mr. Karl Howell   male
891         891        0      3                      Dooley, Mr. Patrick   male
    Age SibSp Parch     Ticket   Fare Cabin Embarked
886  39     0     5     382652 29.125              Q
887  27     0     0     211536 13.000              S
888  19     0     0     112053 30.000   B42        S
889  NA     1     2 W./C. 6607 23.450              S
890  26     0     0     111369 30.000  C148        C
891  32     0     0     370376  7.750              Q
df[500:515,]
    PassengerId Survived Pclass                                           Name
500         500        0      3                             Svensson, Mr. Olof
501         501        0      3                               Calic, Mr. Petar
502         502        0      3                            Canavan, Miss. Mary
503         503        0      3                 O'Sullivan, Miss. Bridget Mary
504         504        0      3                 Laitinen, Miss. Kristina Sofia
505         505        1      1                          Maioni, Miss. Roberta
506         506        0      1     Penasco y Castellana, Mr. Victor de Satode
507         507        1      2  Quick, Mrs. Frederick Charles (Jane Richards)
508         508        1      1  Bradley, Mr. George ("George Arthur Brayton")
509         509        0      3                       Olsen, Mr. Henry Margido
510         510        1      3                                 Lang, Mr. Fang
511         511        1      3                       Daly, Mr. Eugene Patrick
512         512        0      3                              Webber, Mr. James
513         513        1      1                      McGough, Mr. James Robert
514         514        1      1 Rothschild, Mrs. Martin (Elizabeth L. Barrett)
515         515        0      3                              Coleff, Mr. Satio
       Sex Age SibSp Parch           Ticket     Fare Cabin Embarked
500   male  24     0     0           350035   7.7958              S
501   male  17     0     0           315086   8.6625              S
502 female  21     0     0           364846   7.7500              Q
503 female  NA     0     0           330909   7.6292              Q
504 female  37     0     0             4135   9.5875              S
505 female  16     0     0           110152  86.5000   B79        S
506   male  18     1     0         PC 17758 108.9000   C65        C
507 female  33     0     2            26360  26.0000              S
508   male  NA     0     0           111427  26.5500              S
509   male  28     0     0           C 4001  22.5250              S
510   male  26     0     0             1601  56.4958              S
511   male  29     0     0           382651   7.7500              Q
512   male  NA     0     0 SOTON/OQ 3101316   8.0500              S
513   male  36     0     0         PC 17473  26.2875   E25        S
514 female  54     1     0         PC 17603  59.4000              C
515   male  24     0     0           349209   7.4958              S
df[490:495, 1:2]
    PassengerId Survived
490         490        1
491         491        0
492         492        0
493         493        0
494         494        0
495         495        0
df[490:495, c(1,5)]
    PassengerId  Sex
490         490 male
491         491 male
492         492 male
493         493 male
494         494 male
495         495 male
str(df)
'data.frame':   891 obs. of  12 variables:
 $ PassengerId: int  1 2 3 4 5 6 7 8 9 10 ...
 $ Survived   : int  0 1 1 1 0 0 0 0 1 1 ...
 $ Pclass     : int  3 1 3 1 3 3 1 3 3 2 ...
 $ Name       : chr  "Braund, Mr. Owen Harris" "Cumings, Mrs. John Bradley (Florence Briggs Thayer)" "Heikkinen, Miss. Laina" "Futrelle, Mrs. Jacques Heath (Lily May Peel)" ...
 $ Sex        : chr  "male" "female" "female" "female" ...
 $ Age        : num  22 38 26 35 35 NA 54 2 27 14 ...
 $ SibSp      : int  1 1 0 1 0 0 0 3 0 1 ...
 $ Parch      : int  0 0 0 0 0 0 0 1 2 0 ...
 $ Ticket     : chr  "A/5 21171" "PC 17599" "STON/O2. 3101282" "113803" ...
 $ Fare       : num  7.25 71.28 7.92 53.1 8.05 ...
 $ Cabin      : chr  "" "C85" "" "C123" ...
 $ Embarked   : chr  "S" "C" "S" "S" ...
#intsall.packages("visdat")
library(visdat)
vis_dat(df)

library(stargazer)

Please cite as: 
 Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
 R package version 5.2.3. https://CRAN.R-project.org/package=stargazer 
stargazer(df, type="text")

==============================================
Statistic    N   Mean   St. Dev.  Min    Max  
----------------------------------------------
PassengerId 891 446.000 257.354    1     891  
Survived    891  0.384   0.487     0      1   
Pclass      891  2.309   0.836     1      3   
Age         714 29.699   14.526  0.420 80.000 
SibSp       891  0.523   1.103     0      8   
Parch       891  0.382   0.806     0      6   
Fare        891 32.204   49.693  0.000 512.329
----------------------------------------------
library(psych)
psych::describe(df)
            vars   n   mean     sd median trimmed    mad  min    max  range
PassengerId    1 891 446.00 257.35 446.00  446.00 330.62 1.00 891.00 890.00
Survived       2 891   0.38   0.49   0.00    0.35   0.00 0.00   1.00   1.00
Pclass         3 891   2.31   0.84   3.00    2.39   0.00 1.00   3.00   2.00
Name*          4 891 446.00 257.35 446.00  446.00 330.62 1.00 891.00 890.00
Sex*           5 891   1.65   0.48   2.00    1.68   0.00 1.00   2.00   1.00
Age            6 714  29.70  14.53  28.00   29.27  13.34 0.42  80.00  79.58
SibSp          7 891   0.52   1.10   0.00    0.27   0.00 0.00   8.00   8.00
Parch          8 891   0.38   0.81   0.00    0.18   0.00 0.00   6.00   6.00
Ticket*        9 891 339.52 200.83 338.00  339.65 268.35 1.00 681.00 680.00
Fare          10 891  32.20  49.69  14.45   21.38  10.24 0.00 512.33 512.33
Cabin*        11 891  18.63  38.14   1.00    8.29   0.00 1.00 148.00 147.00
Embarked*     12 891   3.53   0.80   4.00    3.66   0.00 1.00   4.00   3.00
             skew kurtosis   se
PassengerId  0.00    -1.20 8.62
Survived     0.48    -1.77 0.02
Pclass      -0.63    -1.28 0.03
Name*        0.00    -1.20 8.62
Sex*        -0.62    -1.62 0.02
Age          0.39     0.16 0.54
SibSp        3.68    17.73 0.04
Parch        2.74     9.69 0.03
Ticket*      0.00    -1.28 6.73
Fare         4.77    33.12 1.66
Cabin*       2.09     3.07 1.28
Embarked*   -1.27    -0.16 0.03