Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions data-raw/df_titanic.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ data("titanic_train")
data("titanic_test")

# Rename columns to lowercase
names(df_ship) <- names(df_ship) %>% tolower()
names(titanic_train) <- names(titanic_train) %>% tolower()
names(titanic_test) <- names(titanic_test) %>% tolower()
names(df_ship) <- names(df_ship) |> tolower()
names(titanic_train) <- names(titanic_train) |> tolower()
names(titanic_test) <- names(titanic_test) |> tolower()

# Check for overlapping names between datasets
df_ship %>%
df_ship |>
filter(tolower(name) %in% tolower(titanic_train$name) &
tolower(name) %in% tolower(titanic_test$name)) %>%
tolower(name) %in% tolower(titanic_test$name)) |>
select(name)

# Create a variable to identify which dataset each row belongs to
trimms <- '["\\\\\\(\\)\\s]'

df <- df_ship %>%
df <- df_ship |>
mutate(
name = str_remove_all(name, '"'),
test = case_when( # there are two Kelly, Mr. James and Connolly, Miss. Kate
Expand All @@ -47,8 +47,8 @@ summary(df$test)
sum(df$test == 0, na.rm = TRUE) # 891
sum(df$test == 1, na.rm = TRUE) # 418

df %>%
filter(is.na(test)) %>%
df |>
filter(is.na(test)) |>
select(name)

titanic_passengers <- df
Expand Down