Exporting to text files

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

Exporting to text files

Ed Siefker
I have dose response data analyzed with the package 'drc'.
'summary(mymodel)' prints my kinetic parameters.  I want
that text in an ASCII text file.  I want to get exactly what I
would get if I copied and pasted from the terminal window.

I've read the documentation on data export to text files here:
https://cran.r-project.org/doc/manuals/r-release/R-data.html#Export-to-text-files

write() does not work.

> summary(mymodel)

Model fitted: Michaelis-Menten (2 parms)

Parameter estimates:

              Estimate Std. Error t-value  p-value
d:(Intercept)  213.435     67.094  3.1811 0.009801 **
e:(Intercept)   94.493     59.579  1.5860 0.143820
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error:

 22.03492 (10 degrees of freedom)
> write(summary(mymodel), "kinetics.txt")
Error in cat(x, file = file, sep = c(rep.int(sep, ncolumns - 1), "\n"),  :
  argument 1 (type 'list') cannot be handled by 'cat'

If I try to unlist(mymodel):
> write(unlist(summary(mymodel)), "kinetics.txt")
I get the following contents of "kinetics.txt":

485.537711262143
4501.62443636671
3821.31920509004
3821.31920509004
3549.67055527084
213.435401944579
94.4931993582911
67.0941460663053
59.5791117361684
3.18113299681396
1.58601222147673
0.00980057624097692
0.143819823442402
MM.2()
continuous
10
4.63571040101587
3.93514151059103
3.93514151059103
3.65540149913749
Michaelis-Menten
2
22.0349202690217
10


How do I get the output of 'summary(mymodel)' verbatim? Why doesn't it
work the way I think it does? What documentation should I read to
understand what's going on here?

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Exporting to text files

Jeff Newmiller
?sink

On May 18, 2018 9:47:25 AM PDT, Ed Siefker <[hidden email]> wrote:

>I have dose response data analyzed with the package 'drc'.
>'summary(mymodel)' prints my kinetic parameters.  I want
>that text in an ASCII text file.  I want to get exactly what I
>would get if I copied and pasted from the terminal window.
>
>I've read the documentation on data export to text files here:
>https://cran.r-project.org/doc/manuals/r-release/R-data.html#Export-to-text-files
>
>write() does not work.
>
>> summary(mymodel)
>
>Model fitted: Michaelis-Menten (2 parms)
>
>Parameter estimates:
>
>              Estimate Std. Error t-value  p-value
>d:(Intercept)  213.435     67.094  3.1811 0.009801 **
>e:(Intercept)   94.493     59.579  1.5860 0.143820
>---
>Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
>Residual standard error:
>
> 22.03492 (10 degrees of freedom)
>> write(summary(mymodel), "kinetics.txt")
>Error in cat(x, file = file, sep = c(rep.int(sep, ncolumns - 1), "\n"),
> :
>  argument 1 (type 'list') cannot be handled by 'cat'
>
>If I try to unlist(mymodel):
>> write(unlist(summary(mymodel)), "kinetics.txt")
>I get the following contents of "kinetics.txt":
>
>485.537711262143
>4501.62443636671
>3821.31920509004
>3821.31920509004
>3549.67055527084
>213.435401944579
>94.4931993582911
>67.0941460663053
>59.5791117361684
>3.18113299681396
>1.58601222147673
>0.00980057624097692
>0.143819823442402
>MM.2()
>continuous
>10
>4.63571040101587
>3.93514151059103
>3.93514151059103
>3.65540149913749
>Michaelis-Menten
>2
>22.0349202690217
>10
>
>
>How do I get the output of 'summary(mymodel)' verbatim? Why doesn't it
>work the way I think it does? What documentation should I read to
>understand what's going on here?
>
>______________________________________________
>[hidden email] 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.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Exporting to text files

David Winsemius
Or capture.output

Sent from my iPhone

> On May 18, 2018, at 12:54 PM, Jeff Newmiller <[hidden email]> wrote:
>
> ?sink
>
>> On May 18, 2018 9:47:25 AM PDT, Ed Siefker <[hidden email]> wrote:
>> I have dose response data analyzed with the package 'drc'.
>> 'summary(mymodel)' prints my kinetic parameters.  I want
>> that text in an ASCII text file.  I want to get exactly what I
>> would get if I copied and pasted from the terminal window.
>>
>> I've read the documentation on data export to text files here:
>> https://cran.r-project.org/doc/manuals/r-release/R-data.html#Export-to-text-files
>>
>> write() does not work.
>>
>>> summary(mymodel)
>>
>> Model fitted: Michaelis-Menten (2 parms)
>>
>> Parameter estimates:
>>
>>             Estimate Std. Error t-value  p-value
>> d:(Intercept)  213.435     67.094  3.1811 0.009801 **
>> e:(Intercept)   94.493     59.579  1.5860 0.143820
>> ---
>> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>>
>> Residual standard error:
>>
>> 22.03492 (10 degrees of freedom)
>>> write(summary(mymodel), "kinetics.txt")
>> Error in cat(x, file = file, sep = c(rep.int(sep, ncolumns - 1), "\n"),
>> :
>> argument 1 (type 'list') cannot be handled by 'cat'
>>
>> If I try to unlist(mymodel):
>>> write(unlist(summary(mymodel)), "kinetics.txt")
>> I get the following contents of "kinetics.txt":
>>
>> 485.537711262143
>> 4501.62443636671
>> 3821.31920509004
>> 3821.31920509004
>> 3549.67055527084
>> 213.435401944579
>> 94.4931993582911
>> 67.0941460663053
>> 59.5791117361684
>> 3.18113299681396
>> 1.58601222147673
>> 0.00980057624097692
>> 0.143819823442402
>> MM.2()
>> continuous
>> 10
>> 4.63571040101587
>> 3.93514151059103
>> 3.93514151059103
>> 3.65540149913749
>> Michaelis-Menten
>> 2
>> 22.0349202690217
>> 10
>>
>>
>> How do I get the output of 'summary(mymodel)' verbatim? Why doesn't it
>> work the way I think it does? What documentation should I read to
>> understand what's going on here?
>>
>> ______________________________________________
>> [hidden email] 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.
>
> --
> Sent from my phone. Please excuse my brevity.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Exporting to text files

JohnDee
In reply to this post by Ed Siefker
On Fri, 18 May 2018 11:47:25 -0500
Ed Siefker <[hidden email]> wrote:

> I have dose response data analyzed with the package 'drc'.
> 'summary(mymodel)' prints my kinetic parameters.  I want
> that text in an ASCII text file.  I want to get exactly what I
> would get if I copied and pasted from the terminal window.
>
> I've read the documentation on data export to text files here:
> https://cran.r-project.org/doc/manuals/r-release/R-data.html#Export-to-text-files
>
> write() does not work.
>
The sink() or capture.output() commands do what you want.  The latter is
less cumbersome if you are working directly with R in a terminal rather
than with a script.  You could also employ the knitr and rmarkdown
packages with RStudio if you plan to include the material in a Word or
Libreoffice document.

JWDougherty

______________________________________________
[hidden email] 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.