histelheim
histelheim

Reputation: 5088

Best way of storing data in 100 objects for later retrieval?

When doing sequencing, I normally apply TraMineR's seqdef function on a dataset to generate a single sequence object:

sequence_object <- seqdef(data)

However, let's say I want to loop through a dataframe and generate 1 sequence object per every chunk of 10 columns. Then I would do something like this:

colpicks <- seq(10,1000,by=10)
mapply(function(start,stop) seqdef(df[,start:stop]), colpicks-9, colpicks)

Now, I want to store these objects in some suitable manner. Two questions:

  1. What is the most suitable way of storing (or maybe just automatically naming) 100 objects, so that I can easily loop through each of them at a later point?
  2. How can I modify my code above so that it stores the data per your answer to (1)?

Upvotes: 0

Views: 68

Answers (1)

Ricardo Saporta
Ricardo Saporta

Reputation: 55350

"Most suitable" is completely subjective and dependent on your goal.
I'm assuming this question is related to your previous question, and thus I would suggest setting the simplify argument of mapply to FALSE

myMatrixList <- mapply(.... , simplify=FALSE)

However, even that is not necessary, as you can just combine the sapply from the previous question and skip the middle step

Upvotes: 1

Related Questions