Improvement to documentation in dput.Rd

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Improvement to documentation in dput.Rd

Korpela Mikko (MML)
If the "Matrix" package is attached, 'example(dget)' fails:

  > library(Matrix)
  > example(dget)
 
  dget> fil <- tempfile()
 
  dget> ## Write an ASCII version of function mean to our temp file
  dget> dput(mean, fil)

  dget> ## And read it back into 'bar'
  dget> bar <- dget(fil)
  Error in initialize(value, ...) : '...' used in an incorrect context

A possible fix would be to use 'dput(base::mean, fil)' instead of
'dput(mean, fil)' in src/library/base/man/dput.Rd .

--
Mikko Korpela

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Improvement to documentation in dput.Rd

Martin Maechler
>>>>> Korpela Mikko (MML)
>>>>>     on Sat, 29 Sep 2018 06:49:25 +0000 writes:

    > If the "Matrix" package is attached, 'example(dget)'
    > fails:
    >> library(Matrix) example(dget)
 
    dget> fil <- tempfile()
 
    dget> ## Write an ASCII version of function mean to our temp
    dget> file dput(mean, fil)

    dget> ## And read it back into 'bar' bar <- dget(fil)
    >   Error in initialize(value, ...) : '...' used in an
    > incorrect context

    > A possible fix would be to use 'dput(base::mean, fil)'
    > instead of 'dput(mean, fil)' in
    > src/library/base/man/dput.Rd .

    > --
    > Mikko Korpela

Thank you, Mikko,
indeed that's an improvement which I have done now (svn 75380).

---------

In an ideal world the deparse()'ing  [equivalent: dput()] of S4
generics and methods would give an expression which is not only
parse()able -- which it is finely here -- but would also be
correct when eval()'ed subsequently.

So in this sense, one could also for a "bug" fix which would provide that.
OTOH we do say in the docs that parse() typically works as
inverse of deparse()  {and hence dget() as inverse of dput()}
but not always...

Martin

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel