[R] convert factor dataframe into numeric matrix
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Oct 24 14:58:51 CEST 2007
On Wed, 24 Oct 2007, sun wrote:
> Bear me if this is a naive question.
>
> I have a dataframe, all lists inside it are factors. When I use
Do you mean 'all columns are factors'? A data frame is a list but usually
does not contain lists.
> as.matrix(df) to convert, I get a character matrix while my intention is to
> get numeric matrix. I can make the convertion iteratively by each list but
> I do think there is some more elegant way of doing this.
>
> please let me know if I missed somthing there.
?data.matrix may be what you are looking for: you gave us too little
detail to be sure.
--
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