Hi,
I have an excel workbook where there are 70 sheets inside. I want to merge them all together. I have used the code below for this. But it throws up an error regarding class of the variable.
How can I solve it?
your_path<-"C:/Users/NITHIN PRADEEP/Downloads/School_wise_assessment_sheet.xlsx"
sheets<-excel_sheets(your_path)
map_dfr(.x = sheets, .f = ~read_excel(your_path, sheet = .x) %>% mutate(sheet = .x)) %>%
writexl::write_xlsx("Merged_master.xlsx")
Error: Can't combine `..1$dise_code` <character> and `..35$dise_code` <double>.
Run `rlang::last_error()` to see where the error occurred
analyse a single sheet to understand the column names, and column types.
Then you can amend this script to use read_excel parameters col_names to pass a vector of the column names, and col_types the corresponding column types you determined
col_types
Either NULL to guess all from the spreadsheet or a character vector containing one entry per column from these options: "skip", "guess", "logical", "numeric", "date", "text" or "list". If exactly one col_type is specified, it will be recycled. The content of a cell in a skipped column is never read and that column will not appear in the data frame output. A list cell loads a column as a list of length 1 vectors, which are typed using the type guessing logic from col_types = NULL, but on a cell-by-cell basis.
oh, I think you were thinking of readr's "ccccii" type notation, but this is readxl, which doesnt have that.
in your case try col_types = c(rep("text",6),"numeric")