Guest User

Untitled

a guest
Nov 1st, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #sample CSV with long file name '2018_October_10_regional_users_action_x'
  2. ID email address action x
  3. 1 365367 joe.schmoe@email.com 1
  4. 2 953164 fake.guy@email.com 0
  5.  
  6. #sample CSV with long file name '2018_October_10_regional_users_action_z'
  7. ID email addresss action z
  8. 1 798842 Jill.fake@email.com 0
  9. 2 100321 madeup.j@email.com 1
  10.  
  11. #code I've been using
  12. setwd(choose.dir())
  13. temp <- list.files(pattern = "\.csv" # picking all the csv's from my folder
  14.  
  15. #I was inserting these all as separate objects, since that's the way I know
  16. # how to do what I need, but super manual
  17. #list2env(
  18. lapply(setNames(temp, make.names(gsub("*.csv$", "", temp))),
  19. read_csv), envir = .GlobalEnv)
  20.  
  21. # Manual way I was dropping my column
  22. 2018_October_10_regional_users_action_x <- select(2018_October_10_regional_users_action_x, -Id)
  23. 2018_October_10_regional_users_action_z <- select(2018_October_10_regional_users_action_z, -Id)
Add Comment
Please, Sign In to add comment