Skip to content

Instantly share code, notes, and snippets.

@lissahyacinth
Last active May 24, 2017 13:21
Show Gist options
  • Save lissahyacinth/2b6a244f6e5b44ed467fc92016588a3e to your computer and use it in GitHub Desktop.
Save lissahyacinth/2b6a244f6e5b44ed467fc92016588a3e to your computer and use it in GitHub Desktop.
Selection without the pain of loading packages.
select_multi <- function(df, cols){
if("data.table" %in% class(df)){
return(df[,c(1:ncol(df))[colnames(df) %in% cols], with = FALSE])
}
df[,c(1:ncol(df))[colnames(df) %in% cols]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment