Skip to content

Instantly share code, notes, and snippets.

@BillPetti
Created September 7, 2015 18:28
Show Gist options
  • Save BillPetti/c83a471face493466fa3 to your computer and use it in GitHub Desktop.
Save BillPetti/c83a471face493466fa3 to your computer and use it in GitHub Desktop.
Function to convert multiple variables to different formats at once
convert.magic <- function(obj, type){
FUN1 <- switch(type, character = as.character, numeric = as.numeric, factor = as.factor)
out <- lapply(obj, FUN1)
as.data.frame(out)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment