Using lapply to subset rows from data frames — incorrect number of dimensions error
问题 I have a list called "scenbase" that contains 40 data frames, which are each 326 rows by 68 columns. I would like to use lapply() to subset the data frames so they only retain rows 33-152. I've written a simple function called trim() (below), and am attempting to apply it to the list of data frames but am getting an error message. The function and my attempt at using it with lapply is below: trim <- function(i) { (i <- i[33:152,]) } lapply(scenbase, trim) Error in i[33:152, ] : incorrect