Skip to content
Back to formatted view

Raw Message

Message-ID: <f8e6ff050809171935o5fabd443vc3125e827cefabd4@mail.gmail.com>
Date: 2008-09-18T02:35:02Z
From: Hadley Wickham
Subject: matrix to list
In-Reply-To: <2947BB7F49B05B4C85A67A4F2E95D9D70E18EEBFF2@wood-site-001.corporateict.domain>

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/