stargazer(
train[, -c(1, 2)], # drop PassengerId & Survived
type = "text",
title = "Table 1: Titanic Summary Statistics",
summary.stat = c("n", "mean", "sd", "min", "max"),
column.labels = c("N", "Mean", "SD", "Min", "Max"),
covariate.labels = c(
"Passenger Class (1 = 1st, 2 = 2nd, 3 = 3rd)",
"Age (years)",
"Siblings/Spouses Aboard",
"Parents/Children Aboard",
"Fare (£)"
),
digits = 2,
align = TRUE,
no.space = TRUE,
add.lines = list(
c("Missing Age", sum(is.na(train$Age))),
c("Missing Cabin", sum(is.na(train$Cabin)))
),
notes = "Source: Kaggle Titanic dataset (N = 891)."
)
Table 1: Titanic Summary Statistics
==========================================================================
Statistic N Mean St. Dev. Min Max
--------------------------------------------------------------------------
Passenger Class (1 = 1st, 2 = 2nd, 3 = 3rd) 891 2.31 0.84 1 3
Age (years) 714 29.70 14.53 0.42 80.00
Siblings/Spouses Aboard 891 0.52 1.10 0 8
Parents/Children Aboard 891 0.38 0.81 0 6
Fare (£) 891 32.20 49.69 0.00 512.33
--------------------------------------------------------------------------
Source: Kaggle Titanic dataset (N = 891).