I have an excel file with multiple sheets, and assign each sheet to a separate variable. I decided to try a for statement like this:
x = 2
for (i in 1:6){
x <- x + 1
assign(paste0(i,"_file"), read.xlsx(file.path(path,"Template.xlsx"), sheetIndex = x, colIndex = 1:5, startRow = 6, stringsAsFactors=FALSE)
)
#remove rows where the entire row is NA (do not remove rows that have some values and/or NA, has to be completely NA)
paste0(i,"_file")<- paste0(i,"_file") %>% filter_at(colnames(paste0(i,"_file")), any_vars(!is.na(.)))
}
the issue is I don't know how to remove rows after I use assign(). After I assign each sheet to a variable, I want to do some cleaning and remove rows that are all NA. I tried to use paste0 and the <- operator but it doesn't work.
UPDATE:
Using list:] but how to remove last 4 rows of each data frame?
x = 2
for (i in 1:6){
x <- x + 1
scoring_raw[[i]] <- read.xlsx(file.path(path,"Template.xlsx"), sheetIndex = x, colIndex = 1:5, startRow = 6, stringsAsFactors=FALSE) %>%
filter_all(any_vars(!is.na(.))) %>% #want to remove last 4 rows of dataframe
}