I'm importing and appending hundreds of Excel spreadsheets into R using map_dfr in combination with a user-defined function:
Function to import specific columns in each worksheet:
fctn <- function(path){map_dfc(.x = c(1,2,3,7,10,11,12,13), ~ read.xlsx(path,
sheet=1,
startRow = 7,
colNames = FALSE,
cols = .x))}
Code to pull all the files in the "path" and append them, where file.list is the list of paths and files to import:
all.files <- map_dfr(file.list, ~ fctn(path=.x))
My problem is, some of these sheets have missing values in some of the columns, but not others, and R doesn't like that. I encounter this error, for instance:
"Error: can't recycle '..1' (size 8) to match '..2' (size 6)", which happens because column 2 is missing information in two cells.
Is there any way to make R accept missing values in cells?