[R] Saving summary outputs in a table form

Ivan Calandra ivan.calandra at uni-hamburg.de
Wed Mar 16 18:58:39 CET 2011


Hi,

You should carefully and thoroughly read the help page for the 
extraction operators. See ?"["

Let's say your output below is in a data.frame called df. You can do 
something like this:
df[, "Mean"]

To select only some specific "phi" rows, you probably need to set some 
regular expressions, see ?grep

Row.names that start with "phi.1.":
grep(pattern="^phi\\.1\\.", x=row.names(df))
Row.names that start with "phi." and end up with "2":
grep(pattern="^phi\\.[0-9]+\\.2$", x=row.names(df))

So in your data.frame:
df[grep(pattern="^phi\\.1\\.", x=row.names(df)), ]
df[grep(pattern="^phi\\.1\\.", x=row.names(df)), "Mean"]

See ?write.table if you want to write a data.frame to a file.

HTH,
Ivan

Le 3/16/2011 15:47, Haillie a écrit :
> Dear R help,
>
> Is there a way to extract a variable ( one column) from my summary
> statistics to save it in a table form?
> My post-factor analysis summary statistics gave me the output below. Is
> there anyway to just save the mean of all the phi? The filename of this
> summary output is postun2010sum. Also is there a way to just save phi(,2) or
> phi(,3) in a table form on my desktop? Any help would be deeply appreciated.
> Thank you very much and I would be grateful for any comments.
>
>                        Mean      SD  Naive SE Time-series SE
> LambdaR.64.6.1   -2.441402 0.37438 0.0118390      0.0099447
> LambdaR.64.6.2    0.918276 0.34265 0.0108355      0.0101326
> LambdaR.64.6.3    0.216445 0.32877 0.0103965      0.0108384
> LambdaR.64.10.1  -0.269011 0.16282 0.0051488      0.0078555
> LambdaR.64.10.2   1.379486 0.20658 0.0065327      0.0070898
> LambdaR.64.10.3   0.235941 0.15448 0.0048851      0.0063958
> phi.1.2           1.095283 0.11438 0.0036170      0.0060156
> phi.1.3          -0.141687 0.16288 0.0051507      0.0101297
> phi.2.2           0.890038 0.11511 0.0036401      0.0057195
> phi.2.3           0.104225 0.15570 0.0049238      0.0090702
> phi.3.2          -0.379830 0.21483 0.0067936      0.0078231
> phi.3.3          -0.266584 0.32148 0.0101661      0.0102912
> phi.4.2          -1.056815 0.37530 0.0118682      0.0149568
> phi.4.3          -1.193200 0.31209 0.0098691      0.0129749
> phi.5.2           0.364988 0.16384 0.0051812      0.0084784
> phi.5.3          -1.324649 0.18231 0.0057652      0.0063309
> phi.6.2          -1.078973 0.41542 0.0131368      0.0154569
> phi.6.3           0.275169 0.44999 0.0142300      0.0157746
> phi.7.2          -1.055651 0.36960 0.0116879      0.0132779
> phi.7.3           0.664266 0.47810 0.0151190      0.0169993
> phi.8.2          -0.869908 0.34998 0.0110672      0.0111003
> phi.8.3           0.276252 0.42348 0.0133915      0.0124475
> phi.9.2          -0.587335 0.26497 0.0083792      0.0090293
> phi.9.3           0.085117 0.37280 0.0117891      0.0134057
> phi.10.2         -0.996298 0.39233 0.0124066      0.0128439
> phi.10.3         -0.392418 0.38979 0.0123263      0.0138242
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Saving-summary-outputs-in-a-table-form-tp3381959p3381959.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>

-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php



More information about the R-help mailing list