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...
-
In K-PAX , there are two possible explanations: Prot is crazy. He is truly an alien. There are facts that indicate 1, but also 2. Examples: ...
-
Why this works? I mean, accessing the private variable. class Test { private $q = 0; public function __construct() { $this-...
-
I found this excellent tutorial on regular expressions and while I intuitively understand what "greedy", "reluctant" an...
No comments:
Post a Comment