Skip to content

Instantly share code, notes, and snippets.

@tengpeng
Created February 7, 2016 05:56
Show Gist options
  • Select an option

  • Save tengpeng/15a08d6375422bd87190 to your computer and use it in GitHub Desktop.

Select an option

Save tengpeng/15a08d6375422bd87190 to your computer and use it in GitHub Desktop.
convert all col to factor
# To do it for all names
col_names <- names(df_all)
# do do it for some names in a vector named 'col_names'
df_all[,col_names] <- lapply(df_all[,col_names] , factor)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment