Is there a method to save a large and complex R object (either as a binary or text file) so that it can be loaded and reused at a later time? Specifically, I am creating large lists (several thousand elements), each element of which is either a vector or a matrix (with ~ 2000 rows). The dimensions of the matrices are not all the same. My ideal would be a set of functions of the form obj <- create() # computes the object save(obj,filename) obj <- load(filename) -- ---------------------------------------------------- Richard Mott | Wellcome Trust Centre tel 01865 287588 | for Human Genetics fax 01865 287697 | Roosevelt Drive, Oxford OX3 7BN
Richard, Check out ?save and ?load. You were correct on those. Do you have questions about "create"? If so, you will probably have to be more specific. Sean ----- Original Message ----- From: "Richard Mott" <rmott at well.ox.ac.uk> To: <r-help at stat.math.ethz.ch> Sent: Monday, September 20, 2004 7:00 AM Subject: [R] persiting complex R objects> Is there a method to save a large and complex R object (either as a > binary or text file) so that it can be loaded and reused at a later > time? Specifically, I am creating large lists (several thousand > elements), each element of which is either a vector or a matrix (with ~ > 2000 rows). The dimensions of the matrices are not all the same. My > ideal would be a set of functions of the form > > obj <- create() # computes the object > save(obj,filename) > obj <- load(filename) > > -- > ---------------------------------------------------- > Richard Mott | Wellcome Trust Centre > tel 01865 287588 | for Human Genetics > fax 01865 287697 | Roosevelt Drive, Oxford OX3 7BN > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide!http://www.R-project.org/posting-guide.html>
>>>>> "Richard" == Richard Mott <rmott at well.ox.ac.uk> >>>>> on Mon, 20 Sep 2004 12:00:49 +0100 writes:Richard> Is there a method to save a large and complex R Richard> object (either as a binary or text file) so that it Richard> can be loaded and reused at a later time? Richard> Specifically, I am creating large lists (several Richard> thousand elements), each element of which is either Richard> a vector or a matrix (with ~ 2000 rows). The Richard> dimensions of the matrices are not all the same. My Richard> ideal would be a set of functions of the form Richard> obj <- create() # computes the object Richard> save(obj,filename) Richard> obj <- load(filename) that sounds alright. I'd use save(*, filename, compress = TRUE) ^^^^^^^^^^^^^^^ if dealing with largish objects. Also note that attach(filename) is an alternative that may be a bit cleaner for your situation that's probably not used enough. Regards, Martin Maechler
did you look at ?save ?load ??? ingmar On 9/20/04 1:00 PM, "Richard Mott" <rmott at well.ox.ac.uk> wrote:> Is there a method to save a large and complex R object (either as a > binary or text file) so that it can be loaded and reused at a later > time? Specifically, I am creating large lists (several thousand > elements), each element of which is either a vector or a matrix (with ~ > 2000 rows). The dimensions of the matrices are not all the same. My > ideal would be a set of functions of the form > > obj <- create() # computes the object > save(obj,filename) > obj <- load(filename)
Richard Mott wrote:> Is there a method to save a large and complex R object (either as a > binary or text file) so that it can be loaded and reused at a later > time? Specifically, I am creating large lists (several thousand > elements), each element of which is either a vector or a matrix (with > ~ 2000 rows). The dimensions of the matrices are not all the same. My > ideal would be a set of functions of the form > > obj <- create() # computes the object > save(obj,filename) > obj <- load(filename) >Have a look at ? dump ? source Peter Wolf
Hi! ?save 'save' writes an external representation of R objects to the specified file. The objects can be read back from the file at a later date by using the function 'load' (or 'data' in some cases). ?load Reload the datasets written to a file with the function 'save'. /E *********** REPLY SEPARATOR *********** On 9/20/2004 at 12:00 PM Richard Mott wrote:>>>Is there a method to save a large and complex R object (either as a >>>binary or text file) so that it can be loaded and reused at a later >>>time? Specifically, I am creating large lists (several thousand >>>elements), each element of which is either a vector or a matrix (with ~ >>>2000 rows). The dimensions of the matrices are not all the same. My >>>ideal would be a set of functions of the form >>> >>>obj <- create() # computes the object >>>save(obj,filename) >>>obj <- load(filename) >>> >>>-- >>>---------------------------------------------------- >>>Richard Mott | Wellcome Trust Centre >>>tel 01865 287588 | for Human Genetics >>>fax 01865 287697 | Roosevelt Drive, Oxford OX3 7BN >>> >>>______________________________________________ >>>R-help at stat.math.ethz.ch mailing list >>>https://stat.ethz.ch/mailman/listinfo/r-help >>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlDipl. bio-chem. Witold Eryk Wolski @ MPI-Moleculare Genetic Ihnestrasse 63-73 14195 Berlin 'v' tel: 0049-30-83875219 / \ mail: witek96 at users.sourceforge.net ---W-W---- http://www.molgen.mpg.de/~wolski wolski at molgen.mpg.de