From p.dalgaard at biostat.ku.dk  Wed Oct 25 19:23:30 2006
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: 25 Oct 2006 19:23:30 +0200
Subject: [Rd] sourcing dput output
In-Reply-To: <971536df0610250831j31b8d90fxa3209cf20e6bbfa3@mail.gmail.com>
References: <971536df0610250758h661fd5cci6791a8e166b9aae3@mail.gmail.com>
	<x2d58gtomk.fsf@viggo.kubism.ku.dk>
	<971536df0610250831j31b8d90fxa3209cf20e6bbfa3@mail.gmail.com>
Message-ID: <x2u01stilp.fsf@turmalin.kubism.ku.dk>

"Gabor Grothendieck" <ggrothendieck at gmail.com> writes:

> Thanks.
> 
> However, that still leaves these questions:
> 
> 1. I assume the changes to the internal representation of rownames is
> behind this but should not dput continue to work exactly the same as
> it used to work???  I would think that the internal representation aspect
> would be just that -- internal and not affect various commands.

dput (and deparse) does reveal internal structure, and is sometimes
used for that purpose. It does have some cases where the
representation is not completely accurate, which is a bit unfortunate,
but awkward to avoid, e.g.

> deparse(1:5)
[1] "c(1, 2, 3, 4, 5)"

but if you parse and evaluate that, you get mode "double", not
"integer". Therefore

> deparse(1:5,control="all")
[1] "as.integer(c(1, 2, 3, 4, 5))"

which evaluates correctly, but may clutter up displays in some
contexts (which escape me just now, but changing the default and
running make check should be illuminating).

[It is probably a generic design error in the S language(s) that there
isn't a parseable representation of every possible object, but that is
a bit late to fix.]
 
> 2. what is the difference between dput and dump supposed to be
> anyways?

They are mostly the same, dump is primarily for storage, dput might
also be for display. Notice that dump works for multiple objects since
it also stores variable names.


> On 25 Oct 2006 17:13:23 +0200, Peter Dalgaard <p.dalgaard at biostat.ku.dk> wrote:
> > "Gabor Grothendieck" <ggrothendieck at gmail.com> writes:
> >
> > > Is this not supposed to work?
> > >
> > > > dput(BOD, file = "/BOD.R")
> > > > source("/BOD.R")
> > > Error in attributes(.Data) <- c(attributes(.Data), attrib) :
> > >         row names must be 'character' or 'integer', not 'double'
> > >
> > > > dput(iris, file = "/iris.R")
> > > > source("/iris.R")
> > > Error in attributes(.Data) <- c(attributes(.Data), attrib) :
> > >         row names must be 'character' or 'integer', not 'double'
> > >
> > > > R.version.string # XP
> > > [1] "R version 2.4.0 Patched (2006-10-07 r39598)"
> > >
> > > I also tried control = "all" as an argument to dput as well as a number
> > > of other control values but did not find one that worked.
> >
> >
> > Eh?
> >
> > > dput(iris, file = "/tmp/iris.R")
> > > source("/tmp/iris.R")
> > Error in attributes(.Data) <- c(attributes(.Data), attrib) :
> >        row names must be 'character' or 'integer', not 'double'
> > > dput(iris, file = "/tmp/iris.R",control="all")
> > > source("/tmp/iris.R")
> > > dput(BOD, file = "/tmp/BOD.R",control="all")
> > > source("/tmp/BOD.R")
> > >
> >
> > Happy as a clam...
> >
> > >  R.version.string
> > [1] "R version 2.4.0 Patched (2006-10-20 r39680)"
> >
> > (SUSE 9.3, local compile)
> > --
> >   O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
> >  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
> >  (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
> > ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907
> >
> 

-- 
   O__  ---- Peter Dalgaard             ?ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907




[Rd] sourcing dput output
Peter Dalgaard