Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gabrielburcea/78fa55fa630384f4232adade65729390 to your computer and use it in GitHub Desktop.
Save gabrielburcea/78fa55fa630384f4232adade65729390 to your computer and use it in GitHub Desktop.
Rename of the variables function
# function to select the columns I need
rename_fct <- function(data, oldnames, newnames){
data_names <- colnames(data)
data_names[which(data_names %in% oldnames)] <- newnames
colnames(data) <- data_names
data
}
data <- rename_fct(df, c("PAT_CODE", "WARD_CODE", "START_DATETIME", "END_DATETIME", "AGE_BAND", "SEX", "episode.order", "spell.end.ward"),
c("IDcol", "Ward", "Arrival", "Discharge", "AgeBand", "Gender", "EpisodeNumber", "LastWard"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment