3 Summary statistics

3.1 Generating a table of summary statistics

# Generate summary statistics for "pt_copy" and assign to new object named "pt_copy_summarystats1"
pt_copy_summarystats1<-describe(pt_copy)
# Print contents of "pt_copy_summarystats1"
pt_copy_summarystats1
##            vars  n    mean      sd  median trimmed     mad     min      max    range  skew
## oecd          1 85    0.29    0.46    0.00    0.25    0.00    0.00     1.00     1.00  0.89
## country*      2 85   43.00   24.68   43.00   43.00   31.13    1.00    85.00    84.00  0.00
## pind          3 85    0.46    0.47    0.42    0.45    0.62    0.00     1.00     1.00  0.13
## pindo         4 85    0.61    0.46    0.90    0.63    0.15    0.00     1.00     1.00 -0.46
## ctrycd        5 85  430.88  284.89  299.00  406.86  240.18  111.00   968.00   857.00  0.63
## col_uk        6 85    0.35    0.48    0.00    0.32    0.00    0.00     1.00     1.00  0.60
## t_indep       7 85  119.73   89.76   92.00  117.48  114.16    6.00   250.00   244.00  0.26
## col_uka       8 85    0.28    0.39    0.00    0.24    0.00    0.00     0.93     0.93  0.71
## col_espa      9 85    0.06    0.13    0.00    0.03    0.00    0.00     0.79     0.79  2.68
## col_otha     10 85    0.22    0.36    0.00    0.16    0.00    0.00     0.98     0.98  1.16
## legor_uk     11 85    0.39    0.49    0.00    0.36    0.00    0.00     1.00     1.00  0.45
## legor_so     12 85    0.13    0.34    0.00    0.04    0.00    0.00     1.00     1.00  2.17
## legor_fr     13 85    0.35    0.48    0.00    0.32    0.00    0.00     1.00     1.00  0.60
## legor_ge     14 85    0.07    0.26    0.00    0.00    0.00    0.00     1.00     1.00  3.29
## legor_sc     15 85    0.06    0.24    0.00    0.00    0.00    0.00     1.00     1.00  3.68
## prot80       16 85   17.46   25.50    2.70   12.24    3.85    0.00    97.80    97.80  1.65
## catho80      17 85   40.69   38.66   27.60   38.92   39.88    0.00    97.30    97.30  0.38
## confu        18 85    0.07    0.26    0.00    0.00    0.00    0.00     1.00     1.00  3.29
## avelf        19 85    0.29    0.26    0.18    0.26    0.21    0.00     0.84     0.84  0.76
## govef        20 81    4.21    1.75    4.48    4.25    1.99    0.84     7.26     6.42 -0.22
## graft        21 81    4.17    1.89    4.24    4.26    2.18    0.74     6.92     6.17 -0.37
## logyl        22 74    9.23    0.90    9.29    9.30    1.15    6.95    10.48     3.52 -0.57
## loga         23 73    8.17    0.61    8.37    8.23    0.58    6.28     9.02     2.73 -0.85
## yrsopen      24 75    0.52    0.54    0.42    0.47    0.53    0.00     4.09     4.09  3.72
## gadp         25 75    0.69    0.20    0.68    0.69    0.24    0.31     1.00     0.69  0.11
## engfrac      26 78    0.14    0.32    0.00    0.06    0.00    0.00     1.00     1.00  1.97
## eurfrac      27 78    0.40    0.44    0.08    0.38    0.12    0.00     1.00     1.00  0.31
## frankrom     28 78    2.87    0.84    2.91    2.86    0.78    0.94     5.64     4.70  0.25
## latitude     29 78   17.96   27.87   17.30   19.13   33.67  -36.89    63.89   100.78 -0.31
## gastil       30 85    2.44    1.23    2.28    2.36    1.65    1.00     4.89     3.89  0.39
## cgexp        31 82   28.82   10.49   28.90   28.50   13.04    9.74    51.18    41.44  0.17
## cgrev        32 78   26.49   10.12   24.16   26.05   10.98    8.92    50.85    41.93  0.34
## ssw          33 71    8.15    6.67    7.17    7.65    8.60    0.13    22.38    22.26  0.41
## rgdph        34 85 6688.63 5495.17 4400.03 6130.45 4371.13  530.22 20782.81 20252.59  0.77
## trade        35 85   78.77   47.34   68.45   73.50   34.38   17.56   343.39   325.82  2.37
## prop1564     36 84   62.07    5.76   63.94   62.49    5.31   49.05    71.70    22.66 -0.60
## prop65       37 84    8.45    4.89    6.47    8.26    5.68    2.30    17.43    15.13  0.23
## federal      38 83    0.16    0.37    0.00    0.07    0.00    0.00     1.00     1.00  1.86
## eduger       39 82   88.58   17.70   93.48   90.55   14.33   40.05   117.11    77.06 -0.94
## spropn       40 77    0.13    0.25    0.00    0.07    0.00    0.00     1.00     1.00  2.22
## yearele      41 81 1965.55   36.85 1981.00 1972.62   16.31 1800.00  1994.00   194.00 -2.13
## yearreg      42 81 1961.48   40.16 1978.00 1969.65   20.76 1800.00  1994.00   194.00 -1.85
## seats        43 85  215.45  162.54  166.00  195.25  127.17   15.00   656.00   641.00  1.06
## maj          44 85    0.39    0.49    0.00    0.36    0.00    0.00     1.00     1.00  0.45
## pres         45 85    0.39    0.49    0.00    0.36    0.00    0.00     1.00     1.00  0.45
## lyp          46 85    8.41    0.97    8.39    8.45    1.25    6.27     9.94     3.67 -0.24
## semi         47 85    0.11    0.31    0.00    0.01    0.00    0.00     1.00     1.00  2.52
## majpar       48 85    0.25    0.42    0.00    0.19    0.00    0.00     1.00     1.00  1.12
## majpres      49 85    0.13    0.33    0.00    0.04    0.00    0.00     1.00     1.00  2.17
## propres      50 85    0.26    0.44    0.00    0.20    0.00    0.00     1.00     1.00  1.08
## dem_age      51 85 1958.34   43.74 1978.00 1967.00   19.27 1800.00  1994.00   194.00 -1.65
## lat01        52 78    0.32    0.19    0.28    0.31    0.20    0.00     0.71     0.71  0.27
## age          53 85    0.21    0.22    0.11    0.17    0.10    0.03     1.00     0.97  1.65
## polityIV     54 80    7.17    3.64    8.11    7.92    2.80   -6.00    10.00    16.00 -1.62
## spl          55 74   -2.18    3.48   -1.69   -2.22    2.85  -11.36    12.59    23.95  0.88
## cpi9500      56 71    4.81    2.38    5.29    4.95    2.46    0.27     8.25     7.98 -0.49
## du_60ctry    57 85    0.71    0.46    1.00    0.75    0.00    0.00     1.00     1.00 -0.89
## magn         58 84    0.47    0.40    0.26    0.46    0.31    0.01     1.00     0.99  0.39
## sdm          59 77    0.35    0.39    0.16    0.32    0.15    0.01     1.00     0.99  0.93
## oecd.x       60 85    0.27    0.45    0.00    0.22    0.00    0.00     1.00     1.00  1.01
## mining_gdp   61 77    4.26    6.72    1.29    2.82    1.51    0.02    37.20    37.18  2.41
## gini_8090    62 72   39.20   10.41   37.52   38.71   12.23   19.49    62.30    42.81  0.35
## con2150      63 85    0.11    0.31    0.00    0.01    0.00    0.00     1.00     1.00  2.52
## con5180      64 85    0.29    0.46    0.00    0.25    0.00    0.00     1.00     1.00  0.89
## con81        65 85    0.49    0.50    0.00    0.49    0.00    0.00     1.00     1.00  0.02
## list         66 84  114.48  129.55   77.67   93.16  115.15    0.00   510.33   510.33  1.19
## maj_bad      67 85    1.06    1.60    0.00    0.77    0.00    0.00     4.89     4.89  1.23
## maj_gin      68 72   16.40   20.96    0.00   13.86    0.00    0.00    62.00    62.00  0.63
## maj_old      69 85    0.08    0.19    0.00    0.04    0.00    0.00     1.00     1.00  3.05
## pres_bad     70 85    1.21    1.69    0.00    0.97    0.00    0.00     4.89     4.89  0.91
## pres_gin     71 72   16.66   22.90    0.00   13.83    0.00    0.00    62.00    62.00  0.71
## pres_old     72 85    0.06    0.16    0.00    0.02    0.00    0.00     1.00     1.00  4.26
## propar       73 85    0.35    0.48    0.00    0.32    0.00    0.00     1.00     1.00  0.60
## lpop         74 60   15.90    1.92   15.94   15.95    1.47   11.61    20.63     9.02 -0.16
## continent*   75 85    3.04    1.06    3.00    3.16    1.48    1.00     4.00     3.00 -0.72
##            kurtosis     se
## oecd          -1.23   0.05
## country*      -1.24   2.68
## pind          -1.89   0.05
## pindo         -1.69   0.05
## ctrycd        -1.08  30.90
## col_uk        -1.65   0.05
## t_indep       -1.54   9.74
## col_uka       -1.44   0.04
## col_espa       9.07   0.01
## col_otha      -0.42   0.04
## legor_uk      -1.82   0.05
## legor_so       2.74   0.04
## legor_fr      -1.65   0.05
## legor_ge       8.96   0.03
## legor_sc      11.71   0.03
## prot80         1.99   2.77
## catho80       -1.59   4.19
## confu          8.96   0.03
## avelf         -0.79   0.03
## govef         -1.11   0.19
## graft         -1.14   0.21
## logyl         -0.53   0.10
## loga           0.12   0.07
## yrsopen       22.32   0.06
## gadp          -1.19   0.02
## engfrac        2.04   0.04
## eurfrac       -1.80   0.05
## frankrom       0.60   0.10
## latitude      -0.98   3.16
## gastil        -1.16   0.13
## cgexp         -0.99   1.16
## cgrev         -0.84   1.15
## ssw           -1.16   0.79
## rgdph         -0.71 596.03
## trade          9.85   5.13
## prop1564      -0.87   0.63
## prop65        -1.60   0.53
## federal        1.46   0.04
## eduger         0.59   1.95
## spropn         4.33   0.03
## yearele        5.16   4.09
## yearreg        3.28   4.46
## seats          0.18  17.63
## maj           -1.82   0.05
## pres          -1.82   0.05
## lyp           -1.04   0.11
## semi           4.39   0.03
## majpar        -0.69   0.05
## majpres        2.75   0.04
## propres       -0.84   0.05
## dem_age        2.05   4.74
## lat01         -1.10   0.02
## age            2.05   0.02
## polityIV       2.20   0.41
## spl            3.85   0.40
## cpi9500       -1.12   0.28
## du_60ctry     -1.23   0.05
## magn          -1.64   0.04
## sdm           -0.95   0.04
## oecd.x        -0.98   0.05
## mining_gdp     6.61   0.77
## gini_8090     -0.80   1.23
## con2150        4.39   0.03
## con5180       -1.23   0.05
## con81         -2.02   0.05
## list           0.79  14.14
## maj_bad        0.04   0.17
## maj_gin       -1.30   2.47
## maj_old        9.57   0.02
## pres_bad      -0.81   0.18
## pres_gin      -1.33   2.70
## pres_old      18.75   0.02
## propar        -1.65   0.05
## lpop          -0.32   0.25
## continent*    -0.82   0.12
vars n mean sd median trimmed mad min max range skew kurtosis se
oecd 1 85 0.2941176 0.4583492 0.0000000 0.2463768 0.0000000 0 1 1 0.8877955 -1.225827 0.0497150
country* 2 85 43.0000000 24.6813020 43.0000000 43.0000000 31.1346000 1 85 84 0.0000000 -1.242428 2.6770631
pind 3 85 0.4600902 0.4659720 0.4188713 0.4508357 0.6210186 0 1 1 0.1317631 -1.887050 0.0505418
pindo 4 85 0.6061366 0.4573739 0.9000000 0.6307480 0.1482600 0 1 1 -0.4581688 -1.691084 0.0496092
ctrycd 5 85 430.8823529 284.8886755 299.0000000 406.8550725 240.1812000 111 968 857 0.6276472 -1.082973 30.9005154
col_uk 6 85 0.3529412 0.4807207 0.0000000 0.3188406 0.0000000 0 1 1 0.6046284 -1.653463 0.0521415

3.2 Exporting a summary statistics table as a CSV file

# add rownames to pt_copy_summarystats1
pt_copy_summarystats1$variable<-rownames(pt_copy_summarystats1)

# make "variables" field the first one in the dataset
pt_copy_summarystats1<-pt_copy_summarystats1 %>% relocate(variable)
# write out summary statistics table as CSV file
write_csv(pt_copy_summarystats1, "/Users/adra7980/Documents/git_repositories/r_primer/written_data/pt_copy_summarystats1.csv")

3.3 Using stargazer to create and export summary statistics

# Make the summary stats into a data frame
pt_copy_df<-as.data.frame(pt_copy)
# Use stargazer to export summary statistics as a text file
stargazer(pt_copy_df, type="text", title="Descriptive Statistics", digits=1, out="summary_stats.txt")
# Use stargazer to export summary statistics as an html file
stargazer(pt_copy_df, type="text", title="Descriptive Statistics", digits=1, out="summary_stats.html")

3.4 Summary statistics and grouping variables

3.4.1 Subsetting summary statistics by group with the describe function

# Creates summary statistics for each continent grouping, and puts results in list named "summary_stats_by_continent"
summary_stats_by_continent<-describeBy(pt_copy, pt_copy$continent)
# Accessing continent-level summary statistics for africa from the "summary_stats_by_continent" list
summary_stats_by_continent[["africa"]]
##            vars  n    mean      sd  median trimmed    mad     min     max   range  skew
## oecd          1 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## country*      2 11    6.00    3.32    6.00    6.00   4.45    1.00   11.00   10.00  0.00
## pind          3 11    0.77    0.42    1.00    0.83   0.00    0.00    1.00    1.00 -1.06
## pindo         4 11    0.77    0.42    1.00    0.83   0.00    0.00    1.00    1.00 -1.06
## ctrycd        5 11  647.55  154.90  684.00  685.56  56.34  199.00  754.00  555.00 -2.13
## col_uk        6 11    0.82    0.40    1.00    0.89   0.00    0.00    1.00    1.00 -1.43
## t_indep       7 11   36.64   19.77   35.00   33.89   5.93    9.00   89.00   80.00  1.38
## col_uka       8 11    0.69    0.35    0.86    0.74   0.02    0.00    0.92    0.92 -1.31
## col_espa      9 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## col_otha     10 11    0.15    0.33    0.00    0.07   0.00    0.00    0.96    0.96  1.58
## legor_uk     11 11    0.82    0.40    1.00    0.89   0.00    0.00    1.00    1.00 -1.43
## legor_so     12 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## legor_fr     13 11    0.18    0.40    0.00    0.11   0.00    0.00    1.00    1.00  1.43
## legor_ge     14 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## legor_sc     15 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## prot80       16 11   22.17   20.23   25.80   19.96  19.57    0.10   64.20   64.10  0.46
## catho80      17 11   19.46   13.67   18.70   18.07  13.20    1.90   49.60   47.70  0.71
## confu        18 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## avelf        19 11    0.71    0.14    0.73    0.73   0.15    0.38    0.84    0.46 -1.15
## govef        20 11    5.37    0.82    5.02    5.25   0.68    4.56    7.26    2.70  0.97
## graft        21 11    5.11    0.77    5.39    5.12   0.80    3.93    6.23    2.30 -0.17
## logyl        22 11    7.93    0.78    7.75    7.90   0.53    6.95    9.13    2.18  0.42
## loga         23 11    7.38    0.66    7.33    7.37   0.55    6.28    8.58    2.29  0.03
## yrsopen      24 11    0.21    0.29    0.16    0.15   0.18    0.00    1.00    1.00  1.72
## gadp         25 11    0.55    0.12    0.54    0.55   0.12    0.37    0.74    0.37  0.28
## engfrac      26 11    0.02    0.04    0.00    0.02   0.00    0.00    0.09    0.09  0.95
## eurfrac      27 11    0.07    0.17    0.00    0.03   0.00    0.00    0.57    0.57  2.24
## frankrom     28 11    2.90    0.51    2.94    2.86   0.56    2.19    3.95    1.77  0.54
## latitude     29 11   -9.14   15.17  -15.81   -9.58   8.49  -29.13   14.77   43.90  0.44
## gastil       30 11    3.59    1.16    4.00    3.66   1.32    1.61    4.89    3.28 -0.48
## cgexp        31 10   27.00    7.63   25.50   27.10   8.58   14.65   38.57   23.92  0.06
## cgrev        32  9   26.15   10.36   23.81   26.15   6.14   17.24   50.85   33.61  1.40
## ssw          33  6    1.67    1.46    0.94    1.67   0.58    0.44    3.80    3.36  0.52
## rgdph        34 11 1899.87 1832.60 1116.28 1522.39 738.30  530.22 6666.77 6136.54  1.50
## trade        35 11   77.34   32.13   69.17   76.87  27.13   30.83  128.12   97.29  0.31
## prop1564     36 11   54.23    4.91   53.23   53.51   2.96   49.05   65.95   16.90  1.19
## prop65       37 11    3.28    1.16    2.80    3.06   0.65    2.34    6.26    3.92  1.47
## federal      38 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## eduger       39 11   73.95   23.54   73.55   73.64  25.47   40.05  110.67   70.62  0.08
## spropn       40 10    0.27    0.42    0.00    0.21   0.00    0.00    1.00    1.00  0.92
## yearele      41  8 1982.50   13.48 1990.50 1982.50   5.19 1965.00 1994.00   29.00 -0.41
## yearreg      42  8 1982.50   13.48 1990.50 1982.50   5.19 1965.00 1994.00   29.00 -0.41
## seats        43 11  151.20  109.96  122.22  136.21  86.65   37.33  400.00  362.67  0.92
## maj          44 11    0.73    0.47    1.00    0.78   0.00    0.00    1.00    1.00 -0.88
## pres         45 11    0.64    0.50    1.00    0.67   0.00    0.00    1.00    1.00 -0.49
## lyp          46 11    7.22    0.81    7.02    7.15   0.88    6.27    8.80    2.53  0.53
## semi         47 11    0.18    0.40    0.00    0.11   0.00    0.00    1.00    1.00  1.43
## majpar       48 11    0.18    0.40    0.00    0.11   0.00    0.00    1.00    1.00  1.43
## majpres      49 11    0.55    0.52    1.00    0.56   0.00    0.00    1.00    1.00 -0.16
## propres      50 11    0.09    0.30    0.00    0.00   0.00    0.00    1.00    1.00  2.47
## dem_age      51 11 1975.82   24.77 1989.00 1981.11   7.41 1910.00 1994.00   84.00 -1.57
## lat01        52 11    0.17    0.08    0.18    0.17   0.05    0.00    0.32    0.32 -0.28
## age          53 11    0.12    0.12    0.05    0.09   0.04    0.03    0.45    0.42  1.57
## polityIV     54 11    2.34    5.56    0.22    2.42   6.75   -6.00   10.00   16.00  0.07
## spl          55  8   -1.55    4.52   -1.54   -1.55   1.91   -6.77    8.23   15.00  0.98
## cpi9500      56  9    5.70    1.15    5.90    5.70   1.14    3.93    7.55    3.61  0.01
## du_60ctry    57 11    0.27    0.47    0.00    0.22   0.00    0.00    1.00    1.00  0.88
## magn         58 11    0.71    0.41    1.00    0.75   0.00    0.02    1.00    0.98 -0.58
## sdm          59  9    0.71    0.45    1.00    0.71   0.00    0.03    1.00    0.97 -0.67
## oecd.x       60 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## mining_gdp   61 10    8.43   11.70    4.10    5.89   5.71    0.02   37.20   37.18  1.39
## gini_8090    62  9   50.25    9.95   54.00   50.25  11.86   35.36   62.30   26.94 -0.19
## con2150      63 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## con5180      64 11    0.27    0.47    0.00    0.22   0.00    0.00    1.00    1.00  0.88
## con81        65 11    0.73    0.47    1.00    0.78   0.00    0.00    1.00    1.00 -0.88
## list         66 11   49.83  119.87    0.00   16.46   0.00    0.00  400.00  400.00  2.22
## maj_bad      67 11    2.73    2.05    3.83    2.80   1.56    0.00    4.89    4.89 -0.32
## maj_gin      68  9   37.31   22.84   41.35   37.31  18.75    0.00   62.00   62.00 -0.71
## maj_old      69 11    0.06    0.07    0.04    0.06   0.06    0.00    0.17    0.17  0.69
## pres_bad     70 11    2.63    2.18    3.83    2.67   1.56    0.00    4.89    4.89 -0.30
## pres_gin     71  9   26.72   26.59   35.36   26.72  39.50    0.00   62.00   62.00  0.04
## pres_old     72 11    0.04    0.05    0.03    0.03   0.04    0.00    0.17    0.17  1.66
## propar       73 11    0.18    0.40    0.00    0.11   0.00    0.00    1.00    1.00  1.43
## lpop         74  3   13.99    0.15   13.92   13.99   0.05   13.88   14.17    0.28  0.36
## continent*   75 11    1.00    0.00    1.00    1.00   0.00    1.00    1.00    0.00   NaN
##            kurtosis     se
## oecd            NaN   0.00
## country*      -1.53   1.00
## pind          -0.79   0.13
## pindo         -0.79   0.13
## ctrycd         3.44  46.70
## col_uk         0.08   0.12
## t_indep        1.88   5.96
## col_uka       -0.14   0.10
## col_espa        NaN   0.00
## col_otha       0.79   0.10
## legor_uk       0.08   0.12
## legor_so        NaN   0.00
## legor_fr       0.08   0.12
## legor_ge        NaN   0.00
## legor_sc        NaN   0.00
## prot80        -0.80   6.10
## catho80       -0.39   4.12
## confu           NaN   0.00
## avelf          0.44   0.04
## govef         -0.17   0.25
## graft         -1.62   0.23
## logyl         -1.43   0.23
## loga          -0.91   0.20
## yrsopen        2.15   0.09
## gadp          -1.38   0.04
## engfrac       -1.09   0.01
## eurfrac        3.76   0.05
## frankrom      -0.69   0.15
## latitude      -1.52   4.57
## gastil        -1.45   0.35
## cgexp         -1.30   2.41
## cgrev          0.71   3.45
## ssw           -1.87   0.60
## rgdph          1.28 552.55
## trade         -1.40   9.69
## prop1564       0.34   1.48
## prop65         1.16   0.35
## federal         NaN   0.00
## eduger        -1.50   7.10
## spropn        -1.07   0.13
## yearele       -2.00   4.77
## yearreg       -2.00   4.77
## seats         -0.20  33.16
## maj           -1.31   0.14
## pres          -1.91   0.15
## lyp           -1.18   0.25
## semi           0.08   0.12
## majpar         0.08   0.12
## majpres       -2.15   0.16
## propres        4.52   0.09
## dem_age        1.64   7.47
## lat01         -0.38   0.03
## age            1.64   0.04
## polityIV      -1.63   1.68
## spl            0.05   1.60
## cpi9500       -1.45   0.38
## du_60ctry     -1.31   0.14
## magn          -1.70   0.12
## sdm           -1.63   0.15
## oecd.x          NaN   0.00
## mining_gdp     0.79   3.70
## gini_8090     -1.71   3.32
## con2150         NaN   0.00
## con5180       -1.31   0.14
## con81         -1.31   0.14
## list           3.64  36.14
## maj_bad       -1.81   0.62
## maj_gin       -1.17   7.61
## maj_old       -1.39   0.02
## pres_bad      -1.92   0.66
## pres_gin      -1.97   8.86
## pres_old       2.10   0.02
## propar         0.08   0.12
## lpop          -2.33   0.09
## continent*      NaN   0.00
# Accessing continent-level summary statistics for africa from the "summary_stats_by_continent" list; alternate syntax
summary_stats_by_continent %>% pluck("africa")
##            vars  n    mean      sd  median trimmed    mad     min     max   range  skew
## oecd          1 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## country*      2 11    6.00    3.32    6.00    6.00   4.45    1.00   11.00   10.00  0.00
## pind          3 11    0.77    0.42    1.00    0.83   0.00    0.00    1.00    1.00 -1.06
## pindo         4 11    0.77    0.42    1.00    0.83   0.00    0.00    1.00    1.00 -1.06
## ctrycd        5 11  647.55  154.90  684.00  685.56  56.34  199.00  754.00  555.00 -2.13
## col_uk        6 11    0.82    0.40    1.00    0.89   0.00    0.00    1.00    1.00 -1.43
## t_indep       7 11   36.64   19.77   35.00   33.89   5.93    9.00   89.00   80.00  1.38
## col_uka       8 11    0.69    0.35    0.86    0.74   0.02    0.00    0.92    0.92 -1.31
## col_espa      9 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## col_otha     10 11    0.15    0.33    0.00    0.07   0.00    0.00    0.96    0.96  1.58
## legor_uk     11 11    0.82    0.40    1.00    0.89   0.00    0.00    1.00    1.00 -1.43
## legor_so     12 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## legor_fr     13 11    0.18    0.40    0.00    0.11   0.00    0.00    1.00    1.00  1.43
## legor_ge     14 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## legor_sc     15 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## prot80       16 11   22.17   20.23   25.80   19.96  19.57    0.10   64.20   64.10  0.46
## catho80      17 11   19.46   13.67   18.70   18.07  13.20    1.90   49.60   47.70  0.71
## confu        18 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## avelf        19 11    0.71    0.14    0.73    0.73   0.15    0.38    0.84    0.46 -1.15
## govef        20 11    5.37    0.82    5.02    5.25   0.68    4.56    7.26    2.70  0.97
## graft        21 11    5.11    0.77    5.39    5.12   0.80    3.93    6.23    2.30 -0.17
## logyl        22 11    7.93    0.78    7.75    7.90   0.53    6.95    9.13    2.18  0.42
## loga         23 11    7.38    0.66    7.33    7.37   0.55    6.28    8.58    2.29  0.03
## yrsopen      24 11    0.21    0.29    0.16    0.15   0.18    0.00    1.00    1.00  1.72
## gadp         25 11    0.55    0.12    0.54    0.55   0.12    0.37    0.74    0.37  0.28
## engfrac      26 11    0.02    0.04    0.00    0.02   0.00    0.00    0.09    0.09  0.95
## eurfrac      27 11    0.07    0.17    0.00    0.03   0.00    0.00    0.57    0.57  2.24
## frankrom     28 11    2.90    0.51    2.94    2.86   0.56    2.19    3.95    1.77  0.54
## latitude     29 11   -9.14   15.17  -15.81   -9.58   8.49  -29.13   14.77   43.90  0.44
## gastil       30 11    3.59    1.16    4.00    3.66   1.32    1.61    4.89    3.28 -0.48
## cgexp        31 10   27.00    7.63   25.50   27.10   8.58   14.65   38.57   23.92  0.06
## cgrev        32  9   26.15   10.36   23.81   26.15   6.14   17.24   50.85   33.61  1.40
## ssw          33  6    1.67    1.46    0.94    1.67   0.58    0.44    3.80    3.36  0.52
## rgdph        34 11 1899.87 1832.60 1116.28 1522.39 738.30  530.22 6666.77 6136.54  1.50
## trade        35 11   77.34   32.13   69.17   76.87  27.13   30.83  128.12   97.29  0.31
## prop1564     36 11   54.23    4.91   53.23   53.51   2.96   49.05   65.95   16.90  1.19
## prop65       37 11    3.28    1.16    2.80    3.06   0.65    2.34    6.26    3.92  1.47
## federal      38 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## eduger       39 11   73.95   23.54   73.55   73.64  25.47   40.05  110.67   70.62  0.08
## spropn       40 10    0.27    0.42    0.00    0.21   0.00    0.00    1.00    1.00  0.92
## yearele      41  8 1982.50   13.48 1990.50 1982.50   5.19 1965.00 1994.00   29.00 -0.41
## yearreg      42  8 1982.50   13.48 1990.50 1982.50   5.19 1965.00 1994.00   29.00 -0.41
## seats        43 11  151.20  109.96  122.22  136.21  86.65   37.33  400.00  362.67  0.92
## maj          44 11    0.73    0.47    1.00    0.78   0.00    0.00    1.00    1.00 -0.88
## pres         45 11    0.64    0.50    1.00    0.67   0.00    0.00    1.00    1.00 -0.49
## lyp          46 11    7.22    0.81    7.02    7.15   0.88    6.27    8.80    2.53  0.53
## semi         47 11    0.18    0.40    0.00    0.11   0.00    0.00    1.00    1.00  1.43
## majpar       48 11    0.18    0.40    0.00    0.11   0.00    0.00    1.00    1.00  1.43
## majpres      49 11    0.55    0.52    1.00    0.56   0.00    0.00    1.00    1.00 -0.16
## propres      50 11    0.09    0.30    0.00    0.00   0.00    0.00    1.00    1.00  2.47
## dem_age      51 11 1975.82   24.77 1989.00 1981.11   7.41 1910.00 1994.00   84.00 -1.57
## lat01        52 11    0.17    0.08    0.18    0.17   0.05    0.00    0.32    0.32 -0.28
## age          53 11    0.12    0.12    0.05    0.09   0.04    0.03    0.45    0.42  1.57
## polityIV     54 11    2.34    5.56    0.22    2.42   6.75   -6.00   10.00   16.00  0.07
## spl          55  8   -1.55    4.52   -1.54   -1.55   1.91   -6.77    8.23   15.00  0.98
## cpi9500      56  9    5.70    1.15    5.90    5.70   1.14    3.93    7.55    3.61  0.01
## du_60ctry    57 11    0.27    0.47    0.00    0.22   0.00    0.00    1.00    1.00  0.88
## magn         58 11    0.71    0.41    1.00    0.75   0.00    0.02    1.00    0.98 -0.58
## sdm          59  9    0.71    0.45    1.00    0.71   0.00    0.03    1.00    0.97 -0.67
## oecd.x       60 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## mining_gdp   61 10    8.43   11.70    4.10    5.89   5.71    0.02   37.20   37.18  1.39
## gini_8090    62  9   50.25    9.95   54.00   50.25  11.86   35.36   62.30   26.94 -0.19
## con2150      63 11    0.00    0.00    0.00    0.00   0.00    0.00    0.00    0.00   NaN
## con5180      64 11    0.27    0.47    0.00    0.22   0.00    0.00    1.00    1.00  0.88
## con81        65 11    0.73    0.47    1.00    0.78   0.00    0.00    1.00    1.00 -0.88
## list         66 11   49.83  119.87    0.00   16.46   0.00    0.00  400.00  400.00  2.22
## maj_bad      67 11    2.73    2.05    3.83    2.80   1.56    0.00    4.89    4.89 -0.32
## maj_gin      68  9   37.31   22.84   41.35   37.31  18.75    0.00   62.00   62.00 -0.71
## maj_old      69 11    0.06    0.07    0.04    0.06   0.06    0.00    0.17    0.17  0.69
## pres_bad     70 11    2.63    2.18    3.83    2.67   1.56    0.00    4.89    4.89 -0.30
## pres_gin     71  9   26.72   26.59   35.36   26.72  39.50    0.00   62.00   62.00  0.04
## pres_old     72 11    0.04    0.05    0.03    0.03   0.04    0.00    0.17    0.17  1.66
## propar       73 11    0.18    0.40    0.00    0.11   0.00    0.00    1.00    1.00  1.43
## lpop         74  3   13.99    0.15   13.92   13.99   0.05   13.88   14.17    0.28  0.36
## continent*   75 11    1.00    0.00    1.00    1.00   0.00    1.00    1.00    0.00   NaN
##            kurtosis     se
## oecd            NaN   0.00
## country*      -1.53   1.00
## pind          -0.79   0.13
## pindo         -0.79   0.13
## ctrycd         3.44  46.70
## col_uk         0.08   0.12
## t_indep        1.88   5.96
## col_uka       -0.14   0.10
## col_espa        NaN   0.00
## col_otha       0.79   0.10
## legor_uk       0.08   0.12
## legor_so        NaN   0.00
## legor_fr       0.08   0.12
## legor_ge        NaN   0.00
## legor_sc        NaN   0.00
## prot80        -0.80   6.10
## catho80       -0.39   4.12
## confu           NaN   0.00
## avelf          0.44   0.04
## govef         -0.17   0.25
## graft         -1.62   0.23
## logyl         -1.43   0.23
## loga          -0.91   0.20
## yrsopen        2.15   0.09
## gadp          -1.38   0.04
## engfrac       -1.09   0.01
## eurfrac        3.76   0.05
## frankrom      -0.69   0.15
## latitude      -1.52   4.57
## gastil        -1.45   0.35
## cgexp         -1.30   2.41
## cgrev          0.71   3.45
## ssw           -1.87   0.60
## rgdph          1.28 552.55
## trade         -1.40   9.69
## prop1564       0.34   1.48
## prop65         1.16   0.35
## federal         NaN   0.00
## eduger        -1.50   7.10
## spropn        -1.07   0.13
## yearele       -2.00   4.77
## yearreg       -2.00   4.77
## seats         -0.20  33.16
## maj           -1.31   0.14
## pres          -1.91   0.15
## lyp           -1.18   0.25
## semi           0.08   0.12
## majpar         0.08   0.12
## majpres       -2.15   0.16
## propres        4.52   0.09
## dem_age        1.64   7.47
## lat01         -0.38   0.03
## age            1.64   0.04
## polityIV      -1.63   1.68
## spl            0.05   1.60
## cpi9500       -1.45   0.38
## du_60ctry     -1.31   0.14
## magn          -1.70   0.12
## sdm           -1.63   0.15
## oecd.x          NaN   0.00
## mining_gdp     0.79   3.70
## gini_8090     -1.71   3.32
## con2150         NaN   0.00
## con5180       -1.31   0.14
## con81         -1.31   0.14
## list           3.64  36.14
## maj_bad       -1.81   0.62
## maj_gin       -1.17   7.61
## maj_old       -1.39   0.02
## pres_bad      -1.92   0.66
## pres_gin      -1.97   8.86
## pres_old       2.10   0.02
## propar         0.08   0.12
## lpop          -2.33   0.09
## continent*      NaN   0.00
# Group-level summary statistics can be assigned to their own object for easy retrieval
asia_europe_summary_statistics<-summary_stats_by_continent %>% pluck("asiae")
# retrieve summary statistics for Asia/Europe 
asia_europe_summary_statistics
##            vars  n    mean      sd  median trimmed     mad     min      max    range  skew
## oecd          1 13    0.00    0.00    0.00    0.00    0.00    0.00     0.00     0.00   NaN
## country*      2 13    7.00    3.89    7.00    7.00    4.45    1.00    13.00    12.00  0.00
## pind          3 13    0.87    0.28    1.00    0.94    0.00    0.00     1.00     1.00 -2.31
## pindo         4 13    0.95    0.09    1.00    0.96    0.00    0.78     1.00     0.22 -1.12
## ctrycd        5 13  623.00  141.16  564.00  605.64   32.62  513.00   924.00   411.00  1.15
## col_uk        6 13    0.54    0.52    1.00    0.55    0.00    0.00     1.00     1.00 -0.14
## t_indep       7 13   74.31   78.67   51.00   62.91   13.34   24.00   250.00   226.00  1.64
## col_uka       8 13    0.45    0.44    0.79    0.45    0.17    0.00     0.90     0.90 -0.12
## col_espa      9 13    0.06    0.22    0.00    0.00    0.00    0.00     0.79     0.79  2.82
## col_otha     10 13    0.39    0.44    0.00    0.38    0.00    0.00     0.90     0.90  0.15
## legor_uk     11 13    0.77    0.44    1.00    0.82    0.00    0.00     1.00     1.00 -1.13
## legor_so     12 13    0.00    0.00    0.00    0.00    0.00    0.00     0.00     0.00   NaN
## legor_fr     13 13    0.08    0.28    0.00    0.00    0.00    0.00     1.00     1.00  2.82
## legor_ge     14 13    0.15    0.38    0.00    0.09    0.00    0.00     1.00     1.00  1.70
## legor_sc     15 13    0.00    0.00    0.00    0.00    0.00    0.00     0.00     0.00   NaN
## prot80       16 13    9.48   18.15    1.40    5.89    1.78    0.00    58.40    58.40  1.77
## catho80      17 13   11.38   23.52    2.80    5.81    3.56    0.00    84.10    84.10  2.28
## confu        18 13    0.38    0.51    0.00    0.36    0.00    0.00     1.00     1.00  0.42
## avelf        19 13    0.46    0.28    0.45    0.47    0.29    0.00     0.80     0.80 -0.31
## govef        20 12    4.60    1.75    4.86    4.79    1.90    0.84     6.49     5.65 -0.69
## graft        21 12    4.76    1.56    5.29    4.93    1.38    1.10     6.71     5.60 -0.85
## logyl        22 12    8.83    0.66    8.62    8.80    0.82    7.92     9.97     2.05  0.30
## loga         23 12    8.05    0.52    8.01    8.03    0.58    7.30     8.90     1.60  0.04
## yrsopen      24 13    0.72    1.09    0.41    0.48    0.60    0.00     4.09     4.09  2.19
## gadp         25 12    0.61    0.17    0.62    0.61    0.20    0.31     0.86     0.55 -0.17
## engfrac      26 13    0.01    0.02    0.00    0.00    0.00    0.00     0.09     0.09  2.63
## eurfrac      27 13    0.01    0.02    0.00    0.00    0.00    0.00     0.09     0.09  2.63
## frankrom     28 13    2.52    0.61    2.59    2.52    0.45    1.19     3.89     2.70  0.07
## latitude     29 13   14.28   16.21   13.92   15.08   16.83  -17.83    37.55    55.38 -0.41
## gastil       30 13    3.52    0.75    3.33    3.54    0.74    2.17     4.67     2.50  0.04
## cgexp        31 13   20.44    5.76   18.48   20.22    4.29   12.57    30.81    18.25  0.47
## cgrev        32 13   19.54    6.81   18.45   19.06    6.91    9.74    34.67    24.94  0.62
## ssw          33 11    1.27    1.29    0.65    1.05    0.77    0.13     4.39     4.26  1.23
## rgdph        34 13 4601.57 4223.17 2441.69 3994.20 1919.26 1147.17 14737.04 13589.87  1.11
## trade        35 13   97.78   84.61   80.63   82.35   45.68   21.88   343.39   321.50  1.79
## prop1564     36 12   60.79    6.17   60.00   60.41    7.40   53.78    71.70    17.92  0.47
## prop65       37 12    4.27    1.16    3.86    4.23    1.15    2.79     6.23     3.44  0.37
## federal      38 13    0.15    0.38    0.00    0.09    0.00    0.00     1.00     1.00  1.70
## eduger       39 12   74.16   20.58   77.72   74.91   20.56   42.15    98.74    56.59 -0.40
## spropn       40 10    0.09    0.12    0.04    0.07    0.06    0.00     0.36     0.36  1.04
## yearele      41 12 1981.94   14.46 1989.00 1984.10    4.45 1950.00  1992.22    42.22 -1.19
## yearreg      42 12 1979.00   17.19 1988.00 1980.80    5.19 1948.00  1992.00    44.00 -0.89
## seats        43 13  229.54  126.01  202.89  217.97  141.01   66.00   520.33   454.33  0.74
## maj          44 13    0.69    0.48    1.00    0.73    0.00    0.00     1.00     1.00 -0.74
## pres         45 13    0.31    0.48    0.00    0.27    0.00    0.00     1.00     1.00  0.74
## lyp          46 13    8.08    0.86    7.80    8.03    0.79    7.05     9.60     2.55  0.40
## semi         47 13    0.23    0.44    0.00    0.18    0.00    0.00     1.00     1.00  1.13
## majpar       48 13    0.57    0.49    0.89    0.59    0.16    0.00     1.00     1.00 -0.29
## majpres      49 13    0.15    0.35    0.00    0.09    0.00    0.00     1.00     1.00  1.69
## propres      50 13    0.16    0.37    0.00    0.10    0.00    0.00     1.00     1.00  1.68
## dem_age      51 13 1977.92   16.91 1988.00 1979.36    5.93 1948.00  1992.00    44.00 -0.73
## lat01        52 13    0.20    0.13    0.20    0.20    0.16    0.02     0.42     0.40  0.03
## age          53 13    0.11    0.08    0.06    0.10    0.03    0.04     0.26     0.22  0.73
## polityIV     54 13    6.24    3.08    6.22    6.65    2.14   -2.00    10.00    12.00 -1.16
## spl          55 13   -1.52    5.32   -1.70   -2.27    4.30   -7.36    12.59    19.95  1.19
## cpi9500      56  9    5.89    2.16    6.90    5.89    1.42    1.00     7.86     6.87 -1.11
## du_60ctry    57 13    0.62    0.51    1.00    0.64    0.00    0.00     1.00     1.00 -0.42
## magn         58 12    0.76    0.32    0.94    0.80    0.08    0.10     1.00     0.90 -0.87
## sdm          59 11    0.52    0.45    0.39    0.53    0.57    0.01     1.00     0.99  0.06
## oecd.x       60 13    0.00    0.00    0.00    0.00    0.00    0.00     0.00     0.00   NaN
## mining_gdp   61 11    2.86    5.07    1.04    1.64    0.96    0.02    16.74    16.72  1.87
## gini_8090    62 11   38.28    7.66   37.55   38.05    8.62   29.03    49.67    20.64  0.27
## con2150      63 13    0.15    0.38    0.00    0.09    0.00    0.00     1.00     1.00  1.70
## con5180      64 13    0.31    0.48    0.00    0.27    0.00    0.00     1.00     1.00  0.74
## con81        65 13    0.62    0.51    1.00    0.64    0.00    0.00     1.00     1.00 -0.42
## list         66 12   25.74   65.45    0.00    8.39    0.00    0.00   224.89   224.89  2.32
## maj_bad      67 13    2.50    1.83    3.17    2.53    1.65    0.00     4.67     4.67 -0.45
## maj_gin      68 11   28.37   19.49   32.00   29.15   20.02    0.00    49.67    49.67 -0.52
## maj_old      69 13    0.08    0.09    0.05    0.07    0.07    0.00     0.25     0.25  0.79
## pres_bad     70 13    1.05    1.71    0.00    0.85    0.00    0.00     4.28     4.28  0.97
## pres_gin     71 11   10.43   18.14    0.00    7.70    0.00    0.00    45.50    45.50  0.97
## pres_old     72 13    0.03    0.07    0.00    0.02    0.00    0.00     0.26     0.26  2.22
## propar       73 13    0.15    0.38    0.00    0.09    0.00    0.00     1.00     1.00  1.70
## lpop         74  8   16.97    2.07   16.83   16.97    1.68   13.57    20.63     7.06  0.10
## continent*   75 13    1.00    0.00    1.00    1.00    0.00    1.00     1.00     0.00   NaN
##            kurtosis      se
## oecd            NaN    0.00
## country*      -1.48    1.08
## pind           4.47    0.08
## pindo         -0.77    0.03
## ctrycd        -0.50   39.15
## col_uk        -2.13    0.14
## t_indep        0.87   21.82
## col_uka       -2.11    0.12
## col_espa       6.44    0.06
## col_otha      -2.10    0.12
## legor_uk      -0.76    0.12
## legor_so        NaN    0.00
## legor_fr       6.44    0.08
## legor_ge       0.99    0.10
## legor_sc        NaN    0.00
## prot80         1.64    5.04
## catho80        4.10    6.52
## confu         -1.96    0.14
## avelf         -1.35    0.08
## govef         -0.68    0.51
## graft         -0.04    0.45
## logyl         -1.39    0.19
## loga          -1.32    0.15
## yrsopen        4.17    0.30
## gadp          -1.31    0.05
## engfrac        5.72    0.01
## eurfrac        5.72    0.01
## frankrom       0.65    0.17
## latitude      -1.06    4.49
## gastil        -1.21    0.21
## cgexp         -1.34    1.60
## cgrev         -0.47    1.89
## ssw            0.40    0.39
## rgdph         -0.03 1171.30
## trade          2.64   23.47
## prop1564      -1.20    1.78
## prop65        -1.50    0.33
## federal        0.99    0.10
## eduger        -1.42    5.94
## spropn        -0.24    0.04
## yearele       -0.18    4.17
## yearreg       -1.10    4.96
## seats         -0.21   34.95
## maj           -1.56    0.13
## pres          -1.56    0.13
## lyp           -1.50    0.24
## semi          -0.76    0.12
## majpar        -1.97    0.13
## majpres        1.02    0.10
## propres        0.94    0.10
## dem_age       -1.30    4.69
## lat01         -1.44    0.04
## age           -1.30    0.02
## polityIV       1.31    0.86
## spl            1.10    1.48
## cpi9500        0.08    0.72
## du_60ctry     -1.96    0.14
## magn          -0.91    0.09
## sdm           -2.06    0.14
## oecd.x          NaN    0.00
## mining_gdp     2.21    1.53
## gini_8090     -1.64    2.31
## con2150        0.99    0.10
## con5180       -1.56    0.13
## con81         -1.96    0.14
## list           4.17   18.89
## maj_bad       -1.56    0.51
## maj_gin       -1.45    5.88
## maj_old       -0.93    0.02
## pres_bad      -0.90    0.48
## pres_gin      -1.02    5.47
## pres_old       4.11    0.02
## propar         0.99    0.10
## lpop          -0.80    0.73
## continent*      NaN    0.00

The “vars” column in the summary statistics table is an index variable; it can be removed with the following:

# removes "vars" indexing variable from "asia_europe_summary_statistics"
asia_europe_summary_statistics<-asia_europe_summary_statistics %>% select(-vars)
# Prints contents of "asia_europe_summary_statistics"
asia_europe_summary_statistics
##             n    mean      sd  median trimmed     mad     min      max    range  skew kurtosis
## oecd       13    0.00    0.00    0.00    0.00    0.00    0.00     0.00     0.00   NaN      NaN
## country*   13    7.00    3.89    7.00    7.00    4.45    1.00    13.00    12.00  0.00    -1.48
## pind       13    0.87    0.28    1.00    0.94    0.00    0.00     1.00     1.00 -2.31     4.47
## pindo      13    0.95    0.09    1.00    0.96    0.00    0.78     1.00     0.22 -1.12    -0.77
## ctrycd     13  623.00  141.16  564.00  605.64   32.62  513.00   924.00   411.00  1.15    -0.50
## col_uk     13    0.54    0.52    1.00    0.55    0.00    0.00     1.00     1.00 -0.14    -2.13
## t_indep    13   74.31   78.67   51.00   62.91   13.34   24.00   250.00   226.00  1.64     0.87
## col_uka    13    0.45    0.44    0.79    0.45    0.17    0.00     0.90     0.90 -0.12    -2.11
## col_espa   13    0.06    0.22    0.00    0.00    0.00    0.00     0.79     0.79  2.82     6.44
## col_otha   13    0.39    0.44    0.00    0.38    0.00    0.00     0.90     0.90  0.15    -2.10
## legor_uk   13    0.77    0.44    1.00    0.82    0.00    0.00     1.00     1.00 -1.13    -0.76
## legor_so   13    0.00    0.00    0.00    0.00    0.00    0.00     0.00     0.00   NaN      NaN
## legor_fr   13    0.08    0.28    0.00    0.00    0.00    0.00     1.00     1.00  2.82     6.44
## legor_ge   13    0.15    0.38    0.00    0.09    0.00    0.00     1.00     1.00  1.70     0.99
## legor_sc   13    0.00    0.00    0.00    0.00    0.00    0.00     0.00     0.00   NaN      NaN
## prot80     13    9.48   18.15    1.40    5.89    1.78    0.00    58.40    58.40  1.77     1.64
## catho80    13   11.38   23.52    2.80    5.81    3.56    0.00    84.10    84.10  2.28     4.10
## confu      13    0.38    0.51    0.00    0.36    0.00    0.00     1.00     1.00  0.42    -1.96
## avelf      13    0.46    0.28    0.45    0.47    0.29    0.00     0.80     0.80 -0.31    -1.35
## govef      12    4.60    1.75    4.86    4.79    1.90    0.84     6.49     5.65 -0.69    -0.68
## graft      12    4.76    1.56    5.29    4.93    1.38    1.10     6.71     5.60 -0.85    -0.04
## logyl      12    8.83    0.66    8.62    8.80    0.82    7.92     9.97     2.05  0.30    -1.39
## loga       12    8.05    0.52    8.01    8.03    0.58    7.30     8.90     1.60  0.04    -1.32
## yrsopen    13    0.72    1.09    0.41    0.48    0.60    0.00     4.09     4.09  2.19     4.17
## gadp       12    0.61    0.17    0.62    0.61    0.20    0.31     0.86     0.55 -0.17    -1.31
## engfrac    13    0.01    0.02    0.00    0.00    0.00    0.00     0.09     0.09  2.63     5.72
## eurfrac    13    0.01    0.02    0.00    0.00    0.00    0.00     0.09     0.09  2.63     5.72
## frankrom   13    2.52    0.61    2.59    2.52    0.45    1.19     3.89     2.70  0.07     0.65
## latitude   13   14.28   16.21   13.92   15.08   16.83  -17.83    37.55    55.38 -0.41    -1.06
## gastil     13    3.52    0.75    3.33    3.54    0.74    2.17     4.67     2.50  0.04    -1.21
## cgexp      13   20.44    5.76   18.48   20.22    4.29   12.57    30.81    18.25  0.47    -1.34
## cgrev      13   19.54    6.81   18.45   19.06    6.91    9.74    34.67    24.94  0.62    -0.47
## ssw        11    1.27    1.29    0.65    1.05    0.77    0.13     4.39     4.26  1.23     0.40
## rgdph      13 4601.57 4223.17 2441.69 3994.20 1919.26 1147.17 14737.04 13589.87  1.11    -0.03
## trade      13   97.78   84.61   80.63   82.35   45.68   21.88   343.39   321.50  1.79     2.64
## prop1564   12   60.79    6.17   60.00   60.41    7.40   53.78    71.70    17.92  0.47    -1.20
## prop65     12    4.27    1.16    3.86    4.23    1.15    2.79     6.23     3.44  0.37    -1.50
## federal    13    0.15    0.38    0.00    0.09    0.00    0.00     1.00     1.00  1.70     0.99
## eduger     12   74.16   20.58   77.72   74.91   20.56   42.15    98.74    56.59 -0.40    -1.42
## spropn     10    0.09    0.12    0.04    0.07    0.06    0.00     0.36     0.36  1.04    -0.24
## yearele    12 1981.94   14.46 1989.00 1984.10    4.45 1950.00  1992.22    42.22 -1.19    -0.18
## yearreg    12 1979.00   17.19 1988.00 1980.80    5.19 1948.00  1992.00    44.00 -0.89    -1.10
## seats      13  229.54  126.01  202.89  217.97  141.01   66.00   520.33   454.33  0.74    -0.21
## maj        13    0.69    0.48    1.00    0.73    0.00    0.00     1.00     1.00 -0.74    -1.56
## pres       13    0.31    0.48    0.00    0.27    0.00    0.00     1.00     1.00  0.74    -1.56
## lyp        13    8.08    0.86    7.80    8.03    0.79    7.05     9.60     2.55  0.40    -1.50
## semi       13    0.23    0.44    0.00    0.18    0.00    0.00     1.00     1.00  1.13    -0.76
## majpar     13    0.57    0.49    0.89    0.59    0.16    0.00     1.00     1.00 -0.29    -1.97
## majpres    13    0.15    0.35    0.00    0.09    0.00    0.00     1.00     1.00  1.69     1.02
## propres    13    0.16    0.37    0.00    0.10    0.00    0.00     1.00     1.00  1.68     0.94
## dem_age    13 1977.92   16.91 1988.00 1979.36    5.93 1948.00  1992.00    44.00 -0.73    -1.30
## lat01      13    0.20    0.13    0.20    0.20    0.16    0.02     0.42     0.40  0.03    -1.44
## age        13    0.11    0.08    0.06    0.10    0.03    0.04     0.26     0.22  0.73    -1.30
## polityIV   13    6.24    3.08    6.22    6.65    2.14   -2.00    10.00    12.00 -1.16     1.31
## spl        13   -1.52    5.32   -1.70   -2.27    4.30   -7.36    12.59    19.95  1.19     1.10
## cpi9500     9    5.89    2.16    6.90    5.89    1.42    1.00     7.86     6.87 -1.11     0.08
## du_60ctry  13    0.62    0.51    1.00    0.64    0.00    0.00     1.00     1.00 -0.42    -1.96
## magn       12    0.76    0.32    0.94    0.80    0.08    0.10     1.00     0.90 -0.87    -0.91
## sdm        11    0.52    0.45    0.39    0.53    0.57    0.01     1.00     0.99  0.06    -2.06
## oecd.x     13    0.00    0.00    0.00    0.00    0.00    0.00     0.00     0.00   NaN      NaN
## mining_gdp 11    2.86    5.07    1.04    1.64    0.96    0.02    16.74    16.72  1.87     2.21
## gini_8090  11   38.28    7.66   37.55   38.05    8.62   29.03    49.67    20.64  0.27    -1.64
## con2150    13    0.15    0.38    0.00    0.09    0.00    0.00     1.00     1.00  1.70     0.99
## con5180    13    0.31    0.48    0.00    0.27    0.00    0.00     1.00     1.00  0.74    -1.56
## con81      13    0.62    0.51    1.00    0.64    0.00    0.00     1.00     1.00 -0.42    -1.96
## list       12   25.74   65.45    0.00    8.39    0.00    0.00   224.89   224.89  2.32     4.17
## maj_bad    13    2.50    1.83    3.17    2.53    1.65    0.00     4.67     4.67 -0.45    -1.56
## maj_gin    11   28.37   19.49   32.00   29.15   20.02    0.00    49.67    49.67 -0.52    -1.45
## maj_old    13    0.08    0.09    0.05    0.07    0.07    0.00     0.25     0.25  0.79    -0.93
## pres_bad   13    1.05    1.71    0.00    0.85    0.00    0.00     4.28     4.28  0.97    -0.90
## pres_gin   11   10.43   18.14    0.00    7.70    0.00    0.00    45.50    45.50  0.97    -1.02
## pres_old   13    0.03    0.07    0.00    0.02    0.00    0.00     0.26     0.26  2.22     4.11
## propar     13    0.15    0.38    0.00    0.09    0.00    0.00     1.00     1.00  1.70     0.99
## lpop        8   16.97    2.07   16.83   16.97    1.68   13.57    20.63     7.06  0.10    -0.80
## continent* 13    1.00    0.00    1.00    1.00    0.00    1.00     1.00     0.00   NaN      NaN
##                 se
## oecd          0.00
## country*      1.08
## pind          0.08
## pindo         0.03
## ctrycd       39.15
## col_uk        0.14
## t_indep      21.82
## col_uka       0.12
## col_espa      0.06
## col_otha      0.12
## legor_uk      0.12
## legor_so      0.00
## legor_fr      0.08
## legor_ge      0.10
## legor_sc      0.00
## prot80        5.04
## catho80       6.52
## confu         0.14
## avelf         0.08
## govef         0.51
## graft         0.45
## logyl         0.19
## loga          0.15
## yrsopen       0.30
## gadp          0.05
## engfrac       0.01
## eurfrac       0.01
## frankrom      0.17
## latitude      4.49
## gastil        0.21
## cgexp         1.60
## cgrev         1.89
## ssw           0.39
## rgdph      1171.30
## trade        23.47
## prop1564      1.78
## prop65        0.33
## federal       0.10
## eduger        5.94
## spropn        0.04
## yearele       4.17
## yearreg       4.96
## seats        34.95
## maj           0.13
## pres          0.13
## lyp           0.24
## semi          0.12
## majpar        0.13
## majpres       0.10
## propres       0.10
## dem_age       4.69
## lat01         0.04
## age           0.02
## polityIV      0.86
## spl           1.48
## cpi9500       0.72
## du_60ctry     0.14
## magn          0.09
## sdm           0.14
## oecd.x        0.00
## mining_gdp    1.53
## gini_8090     2.31
## con2150       0.10
## con5180       0.13
## con81         0.14
## list         18.89
## maj_bad       0.51
## maj_gin       5.88
## maj_old       0.02
## pres_bad      0.48
## pres_gin      5.47
## pres_old      0.02
## propar        0.10
## lpop          0.73
## continent*    0.00

3.4.2 Generating group-level summary statistics with the summarize function from dplyr

# Generate a table that displays summary statistics for trade at the continent level and assign to object named "trade_age_by_continent"
trade_age_by_continent<-pt_copy %>% group_by(continent) %>% 
                                    summarise(meanTrade=mean(trade),sdTrade=sd(trade),
                                              meanAge=mean(age), sdAge=sd(age),
                                              n=n())
# prints contents of "trade_age_by_continent"
trade_age_by_continent
## # A tibble: 4 × 6
##   continent meanTrade sdTrade meanAge  sdAge     n
##   <chr>         <dbl>   <dbl>   <dbl>  <dbl> <int>
## 1 africa         77.3    32.1   0.121 0.124     11
## 2 asiae          97.8    84.6   0.110 0.0846    13
## 3 laam           68.6    32.8   0.139 0.153     23
## 4 other          78.8    40.7   0.309 0.263     38

3.5 Generating crosstabs

3.5.1 Crosstabs with tabyl

# Creates cross-tab showing the breakdown of federal/non federal across continents
crosstab_federal_continent<-pt_copy %>% tabyl(federal, continent)
# Prints contents of "crosstab_federal_continent"
crosstab_federal_continent
##  federal africa asiae laam other
##        0     11    11   19    29
##        1      0     2    4     7
##       NA      0     0    0     2
# Creates cross-tab showing the breakdown of majoritarian/nonmajoritarian across continents
crosstab_majoritarian_continent<-pt_copy %>% tabyl(maj, continent)
# prints contents of "crosstab_majoritarian_continent"
crosstab_majoritarian_continent
##  maj africa asiae laam other
##    0      3     4   16    29
##    1      8     9    7     9

3.5.2 Crosstabs with tbl_cross

# Uses "tbl_cross" function to create crosstab showing breakdown of federal/non-federal by continent
tbl_cross(pt_copy, row=federal, col=continent)
Characteristic continent Total
africa asiae laam other
federal
0 11 11 19 29 70
1 0 2 4 7 13
Unknown 0 0 0 2 2
Total 11 13 23 38 85
# Uses "tbl_cross" function to create crosstab showing breakdown of majoritarian/non majoritarian by continent
tbl_cross(pt_copy, row=maj, col=continent)
Characteristic continent Total
africa asiae laam other
maj
0 3 4 16 29 52
1 8 9 7 9 33
Total 11 13 23 38 85