Hi,
I need to import dataframes to R using for loop from a list:
file.list <- list.files(pattern='*.xls.*', recursive = TRUE)
df.list_excel <- lapply(file.list, read_excel)
for(i in 1:length(df.list_excel)) {
assign(paste0("file_", i), df.list_excel[[i]])
}
I need to delete empty rows in each df when importing dataframes. I tried two ways, neither worked:
library(janitor)
for(i in 1:length(df.list_excel)) {
assign(paste0("file_", i), df.list_excel[[i]]) %>% remove_empty("rows")
}
or
for(i in 1:length(df.list_excel)) {
assign(paste0("file_", i), df.list_excel[[i]]) %>% na.omit
}
Can anybody help me, please? Thanks a lot.