Use purrr::pmap to Combine Spreadsheets

p_load(tidyverse, readxl, purrr)

# download xlsx files from moodle  put in List
file  <- list.files(pattern = "*.xlsx")

# columns (course, group) to add to each spreadsheet
course  <-  c("fa-18-IntAcctA", "fa-18-IntAcctA", "fa-18-AdvAcct")
group  <-  c("12PM", "2PM", "4PM")

files_in  <- function(file, course, group){
file   %>% read_xlsx() %>% select(firstname = `First name`,
  lastname = `Last name`, username = `ID number`, email = `Email address`)  %>%
  mutate(course1 = course, group1 = group)  %>%
  select(firstname, lastname, username, course1, group1, email)

l  <- list(file, course, group )
pmap_dfr(l, files_in)  %>% write_csv("enroll-fa18.csv")
Elizabeth Stanny
Elizabeth Stanny
Professor of Business Administration

My research interests include climate change and political disclosures.