[R] write.table problem
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Apr 24 16:19:18 CEST 2003
On Thu, 24 Apr 2003, Hector L. Ayala-del-Rio wrote:
> Dear R helpers,
> I have been using the loadings function from the multiv library and I
Looks like loadings() from the *mva* package to me, or more precisely
the result of the print method for loadings.
> get the typical output (see below). When I try to export these results
> to a file using a write.table() I get the following error message
> "Error in as.data.frame.default(x[[i]], optional = TRUE) : can't coerce
> loadings into a data.frame" Any idea why write.table is doing that and
> any possible solutions??
?write.table says
`write.table' prints its required argument `x' (after converting
it to a data frame if it is not one already) to `file'.
There is no in-built way to convert a `loadings' object to a data frame,
but as it is a matrix (see ?princomp), unclass(loadings(foo)) will work.
> > write.table(loadings(M2.princomp.corr))
^unclass( ^)
Note that you do get just the loadings, not the full output from
print.loadings.
--
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 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list