user3141121
user3141121

Reputation: 490

filling multidimensional array with dataframe of various dimensions

I'm trying to keep many data frames of varying dimensions in a single multidimensional array. I can do this if all of the data frames have the same dimensions by first creating the array and filling it in with the data. But in this case, the data frames can vary in the number of rows they can have. Any idea how to do this?

Upvotes: 0

Views: 201

Answers (1)

user3471268
user3471268

Reputation:

Answer is probably "you shouldn't be using an array for this". If you want to be able to store all the data frames in one object, you probably want a list - in fact, if you're reading them in immediately before this step, I'd suggest just

list_of_data_frames <- lapply(filelist,read.delim)

This is one of those situations where an explanation of what comes next is really needed for a substantive answer, though.

Really, and I'd emphasise this again, you probably don't want an array - not if you're dealing with data frames. An array is really just a vector with tightly associated metadata; while you can mutate it to convert it out into a data frame, or, well, really anything else, doing so is a pain. I've encountered a grand total of one operation that was well-served by turning a data frame into an array, and it was an improbable operation (composite image generation).

Upvotes: 1

Related Questions