tableone is an R package for fast baseline exploratory data analysis. It puts continuous and categorical variables into one descriptive table, making it useful for getting an initial read on a mixed dataset before deeper analysis. Unlike visual EDA tools, it returns tabular output only. section 17.3 section 17.4.1
A baseline table can quickly answer practical questions: How many records are present? Which categories occur most often? What are the mean and standard deviation of numeric variables? Are values missing? These results establish the scope for later analysis rather than settling the analytical question by themselves. section 17.4 section 17.4.1
Use tableone after preparing the analysis-ready data:
- Load the package with library(tableone). section 17.1
- Keep the variables needed for the initial summary and ensure categorical fields are factors when appropriate. section 17.3
- Pass the dataset to CreateTableOne(data = ...) to create a table object. section 17.4.1
- Call print() for a compact overall table or summary() for more detailed continuous and categorical summaries. section 17.4.1
Baseline summary of NBA betting data
After combining road and home game records, removing identifier and date fields, and converting team, venue, and month fields to factors, create a baseline table with tableOne <- CreateTableOne(data = oddsdf2) and print(tableOne). The resulting table reports 1,230 games, category counts and percentages for teams and venues, and mean (SD) values for points, opening lines, and closing lines. summary(tableOne) adds missingness, medians, quartiles, minima, maxima, skew, and kurtosis for continuous variables. section 17.3 section 17.4.1
tableOne <- CreateTableOne(data = oddsdf2) print(tableOne) ## ## Overall ## n 1230 ## teamR (%) ## Atlanta 41 ( 3.3) ## Boston 41 ( 3.3) ## Brooklyn 41 ( 3.3) ## Toronto 41 ( 3.3) ## Utah 41 ( 3.3) ## Washington 41 ( 3.3) ## venueR = R (%) 1230 (100.0) ## ptsR (mean (SD)) 109.85 (12.48) ## openspreadR (mean (SD)) 2.49 (6.45) ## opentotal (mean (SD)) 221.64 (8.62) ## closespreadR (mean (SD)) 2.62 (6.59) ## closetotal (mean (SD)) 221.69 (8.79) ## teamH (%) ## Atlanta 41 ( 3.3) ## Boston 41 ( 3.3) ## Brooklyn 41 ( 3.3) ## Toronto 41 ( 3.3) ## Utah 41 ( 3.3) ## Washington 41 ( 3.3) ## venueH = H (%) 1230 (100.0) ## ptsH (mean (SD)) 112.57 (12.68) ## openspreadH (mean (SD)) -2.49 (6.45) ## closespreadH (mean (SD)) -2.62 (6.59) ## month2 (%) ## 1 110 ( 8.9) ## 2 219 ( 17.8) ## 3 219 ( 17.8) ## 4 221 ( 18.0) ## 5 158 ( 12.8) ## 6 224 ( 18.2) ## 7 79 ( 6.4)
This listing shows the compact overall table: record count, categorical frequencies and percentages, and mean (SD) summaries appear together. section 17.4.1
In the NBA data, the baseline output supports immediate interpretation: every team appears in 41 road and 41 home games, home teams score more on average than road teams, and point-score variation is similar across venues. It also provides a quick comparison of opening and closing spreads and totals before more focused investigation. section 17.4.1 section 20.9
