0

I'm trying to use lapply to create a list of dataframes, as demonstrated in this answer: https://stackoverflow.com/a/17197201/3843046

My data is in the form of tab separated values, so I have tried this:

temp <- list.files(pattern = "*.txt", full.names = TRUE)
Fresh1 <- lapply(temp,read.table,sep="\t",skip=21,USE.NAMES = TRUE)

And I get this error when running the second line:

Error in FUN(c("./AB5 025.txt", "./AB5 05.txt", "./AB5 1.txt", "./AB5 2.txt",  : 
  unused argument (USE.NAMES = TRUE)

I need to somehow keep the data frames in the list connected with the files they are originating from. Can someone explain how I am misusing USE.NAMES, or if there is another way using lapply or some other method that would perform the same purpose?

Community
  • 1
  • 1
Geoff
  • 23
  • 3
  • @thelatemail `lapply` doesnt use names from `?lapply`: `‘sapply(x, f, simplify = FALSE, USE.NAMES = FALSE)’ is the same as ‘lapply(x, f)’`. @Geoff try `sapply(..., simplify=FALSE)` – Jake Burkhead Feb 16 '15 at 23:51
  • @JakeBurkhead - fair enough, I missed what the OP was meaning, `lapply` retains names as in: `lapply(setNames(1:3,letters[1:3]), FUN=sum)` but won't use a character vector as names, as per `sapply(letters[1:3],paste)` – thelatemail Feb 16 '15 at 23:58

0 Answers0