Skip to content

Instantly share code, notes, and snippets.

@cindyangelira
Created January 9, 2023 10:47
Show Gist options
  • Save cindyangelira/2d0a6cd195e65e8dba909ea91e24d4db to your computer and use it in GitHub Desktop.
Save cindyangelira/2d0a6cd195e65e8dba909ea91e24d4db to your computer and use it in GitHub Desktop.
survival data preprocessing
# Pre processing----
df <- df %>% select(-6)
colnames(df)[c(4,5,6)] <- c("age", "begin", "disease")
# Encoding the categorical feature----
library(caret)
dmy <- dummyVars(" ~ .", data = df)
df_clean <- data.frame(predict(dmy, newdata = df)) %>% select(-c(1,6))
head(df_clean)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment