[R] matrix to list

hadley wickham h.wickham at gmail.com
Thu Sep 18 04:35:02 CEST 2008


On Wed, Sep 17, 2008 at 8:52 PM, Pinder, Adrian
<Adrian.Pinder at dec.wa.gov.au> wrote:
> Hi, can someone please tell me how to convert a square matrix to a list in R?
>
> i.e. I want to convert from:
>
>        a       b       c
> a       1       1       1
> b       2       2       2
> c       3       3       3
>
> to:
>
> a       a       1
> a       b       1
> a       c       1
> b       a       2
> b       b       2
> b       c       2
> c       a       3
> c       b       3
> c       c       3

Try melt from the reshape package.

Hadley

-- 
http://had.co.nz/



More information about the R-help mailing list