Z

Replicating Results in R

Preparing the data used for this section.

library(MASS)

library(tidyverse)
library(tidymodels)

library(pscl)

# load the tips data
tips <- readr::read_csv("data/tips.csv")

# load the titanic data
titanic <- readr::read_csv("data/titanic.csv")

# subset the columns and drop missing values
titanic_sub <- titanic %>%
  dplyr::select(survived, sex, age, embarked) %>%
  tidyr::drop_na()

# load the ACS data and fix the data types
acs <- readr::read_csv("data/acs_ny.csv") %>%
  dplyr::mutate( # data gets loaded differently from pandas
    NumChildren = as.integer(NumChildren),
    FamilyIncome = as.numeric(FamilyIncome),
    NumBedrooms = as.numeric(NumBedrooms),
    HouseCosts = as.numeric(HouseCosts),
    ElectricBill ...

Get Pandas for Everyone: Python Data Analysis, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.