user1125946
user1125946

Reputation:

Storing an arbitrary R object onto HDD?

I understand that we can export data matrices to csv or xlsx files.

What about complex objects like lm? For example, in my work I might have a list of length 1000, each with a single lm() object. Each time I load R I have to wait a long time to populate the 1000 length list with these lm objects with a for loop or a lapply.

I would rather just save the list somewhere on my HDD at the end of a session and open it at the start of the next session.

Upvotes: 6

Views: 160

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368251

Yes, use save(), together with its counterpart load().

In general, this topic is called "serialization" (see help(serialize) ) and R has a lot of support for different formats.

Upvotes: 8

Related Questions