From simon.urbanek at r-project.org  Tue Aug 28 20:00:00 2012
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Tue, 28 Aug 2012 14:00:00 -0400
Subject: [Rd] Don't dput() data frames?
In-Reply-To: <CAAmySGMtCb9dA1=iNZ_FW8J4498q93RcPjAQFTr5cj_f7YzjPw@mail.gmail.com>
References: <CAAmySGMtCb9dA1=iNZ_FW8J4498q93RcPjAQFTr5cj_f7YzjPw@mail.gmail.com>
Message-ID: <DE41AE7A-F75D-40AF-B9C9-AF70A6771489@r-project.org>


On Aug 28, 2012, at 1:51 PM, R. Michael Weylandt wrote:

> /src/main/attrib.c contains this comment in row_names_gets():
> 
>  /* This should not happen, but if a careless user dput()s a
>           data frame and sources the result, it will */
> 
> which svn blame says Prof Ripley placed there in r39830 with the
> commit message "correct the work of dput() on the row names of a data
> frame with compact representation."
> 
> Is there a problem / better way to use the result of a hefty dput than
> source()ing it?

It's pretty much the least efficient and most dangerous (as in insecure) way. That's why there is serialization instead ...

Cheers,
Simon



> This seems to work rather robustly:
> 
> data(iris)
> source(textConnection(paste0("iris2 <- ", capture.output(dput(iris)))))
> identical(iris, iris2)
> 
> Cheers,
> Michael
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 



[Rd] Don't dput() data frames?
Simon Urbanek