I'm an R beginner and trying to read in a number of csv files, remove/skip the last 5 rows from each one, and then rbind them together. I can't figure out which step to do the removal of the rows and what function to use? I've tried readLines
below and then tried to use nrow, but I'm pretty sure its in the wrong place.
This was what I started with:
alldata <- do.call(rbind, lapply(list.files(path = "./savedfiles", full.names = TRUE), read.csv))
I wasn't sure where to remove the rows in that code so I split it up to understand it and try to use readLines
:
files<- list.files(path = "./savedfiles", full.names = TRUE)
c <- lapply(files, readLines) - to count the rows
alldata<- do.call(rbind,lapply(files, nrow = length(f) - 5, full.names = TRUE), read.csv)
This is just throwing an error that argument FUN is missing, so I know I'm not doing it right but not sure how to fix it.