[R] function that converts data into a form that can be included in a question to mailing list

William Dunlap wdunlap at tibco.com
Thu Aug 25 01:06:43 CEST 2016


dump("yourObject", file=stdout()) is, IMO, a bit nicer than plain
dput(yourObject).  It makes copying and pasting even easier by putting
"yourObject <-" in front of dput()'s output so readers don't have to type
that themselves.

E.g.,
> myData <- data.frame(X=1:2, Y=c(exp(1), pi))
> dump("myData", file=stdout())
myData <-
structure(list(X = 1:2, Y = c(2.71828182845905, 3.14159265358979
)), .Names = c("X", "Y"), row.names = c(NA, -2L), class = "data.frame")
> dput(myData)
structure(list(X = 1:2, Y = c(2.71828182845905, 3.14159265358979
)), .Names = c("X", "Y"), row.names = c(NA, -2L), class = "data.frame")




Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Aug 24, 2016 at 3:12 PM, John Sorkin <jsorkin at grecc.umaryland.edu>
wrote:

> Jim,
> Yes, you are correct!
> Give yourself a pat on the back and a gold start
> THANK YOU,
> John
>
>
> John David Sorkin M.D., Ph.D.
> Professor of Medicine
> Chief, Biostatistics and Informatics
> University of Maryland School of Medicine Division of Gerontology and
> Geriatric Medicine
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
> (Phone) 410-605-7119
> (Fax) 410-605-7913 (Please call phone number above prior to faxing)
> >>> Jim Lemon <drjimlemon at gmail.com> 08/24/16 6:05 PM >>>
> Hi John,
> I think it is "dput".
>
> Jim
>
>
> On Thu, Aug 25, 2016 at 8:00 AM, John Sorkin
> <jsorkin at grecc.umaryland.edu> wrote:
> >
> > There is a function that can be used to convert data structures such as
> a data frame into a different format that allows the data to be sent to the
> mailing list. The structure that is created can be used to easily
> reconstruct the data structure. Unfortunately, I don't remember the
> function that is called on the data structure. Can someone remind me?
> > Thank you
> > John
> > John David Sorkin M.D., Ph.D.
> > Professor of Medicine
> > Chief, Biostatistics and Informatics
> > University of Maryland School of Medicine Division of Gerontology and
> Geriatric Medicine
> > Baltimore VA Medical Center
> > 10 North Greene Street
> > GRECC (BT/18/GR)
> > Baltimore, MD 21201-1524
> > (Phone) 410-605-7119
> > (Fax) 410-605-7913 (Please call phone number above prior to faxing)
> >
> > Confidentiality Statement:
> > This email message, including any attachments, is for the sole use of
> the intended recipient(s) and may contain confidential and privileged
> information. Any unauthorized use, disclosure or distribution is
> prohibited. If you are not the intended recipient, please contact the
> sender by reply email and destroy all copies of the original message.
> > ______________________________________________
> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> Confidentiality Statement:
> This email message, including any attachments, is for ...{{dropped:16}}



More information about the R-help mailing list