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...
-
How can I detect either numbers or letters in a string? I am aware you use the ASCII codes, but what functions take advantage of the...
-
I want to create an options array from a string. How can i create an array as { width : 100, height : 200 } from a string ...
No comments:
Post a Comment