From ripley at stats.ox.ac.uk  Wed Oct 17 10:35:15 2007
From: ripley at stats.ox.ac.uk (ripley at stats.ox.ac.uk)
Date: Wed, 17 Oct 2007 10:35:15 +0200 (CEST)
Subject: [Rd] dget not restoring dput in R 2.6.0 (PR#10350)
Message-ID: <20071017083515.93656283416B@mail.pubhealth.ku.dk>

On Wed, 17 Oct 2007, dstates at umich.edu wrote:

> Full_Name: David States
> Version: 2.6.0
> OS: Windows XP64
> Submission from: (NULL) (141.211.38.9)
>
>
> # The pair of commands
> #
> # dput(object, "file.dput")
> # object = dget("file.dput")
> #
> # should be a no op, but this is not working correctly for all objects.

Not so, and it says so on the help page:

      Deparsing an object is difficult, and not always possible.  With
      the default 'control', 'dput()' attempts to deparse in a way that
      is readable, but for more complex or unusual objects, not likely
      to be parsed as identical to the original.  Use 'control = "all"'
      for the most complete deparsing; use 'control = NULL' for the
      simplest deparsing, not even including attributes.

Had you followed the advice, your example would have worked.

dump() is more accurate than dput(), and save() more so than either.

> #
> # Simple example:
> #
> # make a simple object of class "hclust"
> cl = hclust(dist(matrix(nrow=4,ncol=4, c(1:16))))
> # save it to a file using dput
> dput(cl, "cl.dput")
> # the following two commands should give identical results, but they dont
> str(cl)
> str(dget("cl.dput"))
> # plot also fails to interpret the labels on the restore object correctly
> par(mfrow=c(2,1))
> plot(cl)
> plot(dget("cl.dput"))
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] dget not restoring dput in R 2.6.0 (PR#10350)
ripley at stats.ox.ac.uk