Skip to content

Instantly share code, notes, and snippets.

@verajosemanuel
Created March 3, 2021 08:53
Show Gist options
  • Save verajosemanuel/0dfc0c6ea54ed8e49a3f64e51a1b2561 to your computer and use it in GitHub Desktop.
Save verajosemanuel/0dfc0c6ea54ed8e49a3f64e51a1b2561 to your computer and use it in GitHub Desktop.
#stack a #list of #dataframes from #files with #filename in #R
documents <- list.files("data/txt", full.names = T)
# using purr
words <- data_frame(file = documents) %>% mutate(text = map(file, read_lines)) %>% unnest()
# using old-skool apply
words2 <- data_frame(file = documents) %>% mutate(text = lapply(file, read_lines)) %>% unnest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment