0

I am creating a list of filenames new <- as.list(filename1) which looks like below:

[[9]]
[1] "test/a.csv"

[[10]]
[1] "test/b.csv"

and then I am writing the below lapply to load each file to a data.frame(df) assuming that lapply will go over calling read.csv for every element in list

df <- lapply(new,read.csv)

But then when I check the typeof(df) its still a list will all values loaded from my files.

why would it not return me a data.frame rather a list?

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
Suren Baskaran
  • 1,228
  • 1
  • 10
  • 17

1 Answers1

0

From the question, I assume you want to produce a single data frame combining the values from all of your files. If that's the case (and if every file contains the same columns in the same order etc.) you can try:

df <- Map(read.csv, new)
df2 <- do.call(rbind, df)
stuwest
  • 910
  • 1
  • 6
  • 14