I'm working on an excel spreadsheet with many sheets, each sheet represents a kind of product, and every sheet consists of the same table structure, but what really sad is, the only distinction between all those tables is the sheet name and nothing represents in the table. Thus, to bind them together and make me not messy them up, I have to add the sheet name as a primary key to the table.
I want to read them all in one map to a list of data frames, then use
bind_rows() to bind them into a whole, my solutions works like that way:
library(dplyr) name = c("dog", "cat") exmp = data.frame(num = rnorm(100)) # to the real data, it is map(name, ~ read_excel(path, sheet = .), and these works as expected purrr::map(name, ~ exmp %>% mutate(tag = .))
it results in:
Error in tbl_df(.data) : argument ".data" is missing, with no default
I know an explicit loop can solve that, but I'm interested in a "tidy" way and these phenomenon may relate to NSE I suppose, and I'm interested in what really happens inside the function.