Last active
April 13, 2018 00:54
-
-
Save jkaupp/96ee6f153156d5322483118e995ee077 to your computer and use it in GitHub Desktop.
Reading in multiple tables in excel file, groups delimited by #
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(rlang) | |
merge_tbls <- function(x) { | |
col <- sym(names(x)[1]) | |
idx <- filter(x, grepl("#", !!col)) %>% | |
pull(!!col) %>% | |
parse_number() | |
filter(x, !grepl("#", !!col)) %>% | |
mutate(group = idx) | |
} | |
split(df, cumsum(seq_along(df$col1) %in% which(grepl("#", df$col1))[-1])) %>% | |
map_dfr(merge_tbls) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment