0

I have checked both this, this, this, and this but, although this sounds like a basic question, either I've not been able to solve my issue or they propose loop-solutions, which I want to avoid.

I am reading multiple .csv files, using lapply() and read.csv().

As a result, I get a list of lists:

dfs <- list.files(pattern = "^[0-9]") |> lapply(read.csv)
dfs[1] |> class()
#> [1] "list"

How can I make every element of dfs a data frame?

Note that this answer does not fully solve the issue, as I would like to end up with a list of data frames instead of multiple data frames in the global environment.

Matteo
  • 2,774
  • 1
  • 6
  • 22
  • Each item is a data.frame, you are just extracting them incorrectly. Use `[[` rather than `[` to extract the element from the list rather than just subsetting the list. – MrFlick Aug 19 '21 at 17:27
  • @MrFlick Yes, I just realised this question is one of those cases where someone has a problem which they think is caused by something, and ask about this latter something, which however is not the real cause of the problem... I'm sure this scheme has been given an actual name. – Matteo Aug 19 '21 at 17:42
  • That's the basic idea behind the [XY Problem](https://xyproblem.info/). – MrFlick Aug 19 '21 at 18:00
  • @MrFlick That's exactly what I was referring to. If you don't mind, could you take a look at the [new question](https://stackoverflow.com/q/68852713/12391423) I asked? I would appreciate. – Matteo Aug 19 '21 at 18:08

0 Answers0