Saturday 25 March 2017
r - List of excel files is read in as list of lists
Answer
I have a directory of 332 Excel files which I'm reading into R as follows:
list_files <- list.files(path = "C:/Users/mslomka/Documents/R/Datasets/Week 2", pattern = ".csv")
read_files <- lapply(list_files, read.csv)
However, when I subset the read_files
list, all the components are lists rather than data frames/matrices (which is what they should be, given that they are Excel files).
I would like to either (a) read all the excels in as data frame, or (b) create a loop that coerces each of the lists into a data frame.
I have tried several approaches for (b) but none have worked, for example lapply(read_files, as.data.frame)
. I have only managed to coerce individual lists into data frames, for example by doing as.data.frame(read_files[1])
.
Any help would be greatly appreciated!
c++ - Does curly brackets matter for empty constructor?
Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...
-
A fair amount of the second act of The Dark Knight Rises has a class warfare plotline. This is foreshadowed in the trailers with Selina Ky...
-
i have added this sql in my code , function devenir_client_dataforform() { $type = $_POST['clientType']; //$produit...
-
I'm still trying to wrap my head around how the following expression results in undefined behavior: a = a++; Upon searching SO...
No comments:
Post a Comment