[R] exporting an output of an analysis

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jan 9 11:16:00 CET 2002


On 9 Jan 2002, Peter Dalgaard BSA wrote:

> Indbryn Morten <Morten.Indbryn at indman.sintef.no> writes:
>
> > Hi
> >
> > I am now doing a principal component analysis for a data set. This dataset
> > inludes above 100 variables so the output matrix of the analysis is also
> > big. Because the output matrix is so huge it is a problem to use the browser
> > of R to look at the analysis. Therefor I want to export the solution of the
> > principal component analysis to another tool which better fittet for viewing
> > big matrixes/outputs (e.g a database or spreadsheet)
> >
> > The problem is the data format of the output of the solution. It is a
> > mixture of text and numbers. I have tried to convert the output solution to
> > a matrix or a dataframe but is not possible because of the text in the
> > analysis.
> >
> > If somebody have an idea of how to view the output of the analysis in a good
> > way, I would have been really greatfull
>
> [A general output delivery system for R could be a good idea, but it
> looks like a massive undertaking...]
>
> You probably need to extract just the loadings from the princomp
> objects before converting them to a dataframe.

Well, I was going to suggest

edit(loadings(pcoutput))

which works just fine for me (as a spreadsheet).  Not clear that you
really want to look at 100 principal components anyway (a few often
suffice) nor that you want to look at the loadings but rather to plot the
data on the pcs.

An alternative would be

page(loadings(pcoutput), method="print")

to use your favourite pager.

> You might then use write.table() to a CSV file and import it to
> Excel/Gnumeric/whatever
>
> Or maybe use
>
> view.mat <- function(m)invisible(edit(as.data.frame(m)))
>
> as in
>
> pc <- princomp(....)
> summary(pc)
> view.mat(loadings(pc))
>
> (I don't use PCA enough to remember the relative usefulness of
> princomp and prcomp...)

prcomp is for S2-compatibility.

>
> BTW: The summary() method for princomp has explicit print() statements
> inside, which I think we now consider bad style. It should generate an
> object of class "summary.princomp" and there ought to be a
> print.summary.princomp() doing the actual printing.

Yes, but it doesn't generate any new quantities, so summary.princomp would
be pretty simple.  I think that style advice only applies when the summary
object actually generates summaries.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list