Hello Jim,

This graphics.off() helps me to release the previous pdf file that was had the 
error message. Thanks again for your help!

Cheers,

Rebecca

From: jim holtman [mailto:jholt...@gmail.com]
Sent: Thursday, March 21, 2013 10:07 AM
To: Yuan, Rebecca
Cc: R help
Subject: Re: [R] How to store data frames into pdf file and csv file.

If you are getting an error when trying to open the PDF file, then you may of 
had a error writing out a previous file.  I always issue the following command 
to clear out any pending graphic output:

graphics.off()


On Thu, Mar 21, 2013 at 9:49 AM, Yuan, Rebecca 
<rebecca.y...@bankofamerica.com<mailto:rebecca.y...@bankofamerica.com>> wrote:
Hello Jim,

I tried the following as you mentioned, but I still do not have the error while 
opening the pdf file.

pdf(file = result2, paper = "a4r")
                mdl.summary.out            <-capture.output(mdl.summary)
                plot.new()
                text(0,0,paste(mdl.summary.out,collapse='\n'),family='mono')
                dev.off()

I believe this time we try to use pdf to catch the graph via text, are we?

Thanks,

Rebecca

From: jim holtman [mailto:jholt...@gmail.com<mailto:jholt...@gmail.com>]
Sent: Thursday, March 21, 2013 9:44 AM
To: Yuan, Rebecca
Cc: R help
Subject: Re: [R] How to store data frames into pdf file and csv file.

Here is one way of doing it:

> x
               est.coef      std.err    t.stat
intercept  0.0011625517 0.0002671437  4.351784
aa        -0.0813727439 0.0163727943 -4.969997
dummy1    -0.0002534873 0.0001204000 -2.105376
dummy2    -0.0007784864 0.0001437537 -5.415417
bb        -0.0002856727 0.0001090387 -2.619920
cc         0.0003563825 0.0001114803  3.196820
> # capture the output as a string vector
> xo <- capture.output(x)
> plot.new()  # new page
> # now add text to plot
> text(0, 0, paste(xo, collapse = '\n'), family = 'mono')


On Thu, Mar 21, 2013 at 9:20 AM, Yuan, Rebecca 
<rebecca.y...@bankofamerica.com<mailto:rebecca.y...@bankofamerica.com>> wrote:
Hello,

I have a data frame

> mdl.summary
                               est.coef      std.err    t.stat
intercept                  0.0011625517 0.0002671437  4.351784
aa                     -0.0813727439 0.0163727943 -4.969997
dummy1                      -0.0002534873 0.0001204000 -2.105376
dummy2              -0.0007784864 0.0001437537 -5.415417
bb                   -0.0002856727 0.0001090387 -2.619920
cc                    0.0003563825 0.0001114803  3.196820


and would like to store it to a pdf file, I use

                pdf(file = "a.pdf", paper = "a4r")
                mdl.summary
                dev.off()

to store this mdl.summary into a pdf file a.pdf. However, I can see from the 
terminal that:


> pdf(file = result2, paper = "a4r")

> mdl.summary

                               est.coef      std.err    t.stat

intercept                  0.0011625517 0.0002671437  4.351784

aa                     -0.0813727439 0.0163727943 -4.969997

dummy1             -0.0002534873 0.0001204000 -2.105376

dummy2              -0.0007784864 0.0001437537 -5.415417

bb                   -0.0002856727 0.0001090387 -2.619920

cc                     0.0003563825 0.0001114803  3.196820

> dev.off()

pdf

  2

And when I open the a.pdf, the error message says "There was an error opening 
this document. The file is already open or in use by another application." How 
could I save this data frame into a pdf file?

If I have another data frame, such as


> st = data.frame(est.aic, est.aic)

> st

    est.aic est.aic.1

1 -1654.986 -1654.986

How could I save it to a .csv file?

Thanks very much!

Cheers,

Rebecca

----------------------------------------------------------------------
This message, and any attachments, is for the intended r...{{dropped:5}}

______________________________________________
R-help@r-project.org<mailto:R-help@r-project.org> mailing list
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.



--
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
________________________________
This message, and any attachments, is for the intended recipient(s) only, may 
contain information that is privileged, confidential and/or proprietary and 
subject to important terms and conditions available at 
http://www.bankofamerica.com/emaildisclaimer. If you are not the intended 
recipient, please delete this message.



--
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

----------------------------------------------------------------------
This message, and any attachments, is for the intended recipient(s) only, may 
contain information that is privileged, confidential and/or proprietary and 
subject to important terms and conditions available at 
http://www.bankofamerica.com/emaildisclaimer.   If you are not the intended 
recipient, please delete this message.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to