Message-ID: <f8e6ff050904240548i7a94f206n9a65498cc217bc3a@mail.gmail.com>
Date: 2009-04-24T12:48:53Z
From: Hadley Wickham
Subject: Generalized 2D list/array/whatever?
In-Reply-To: <49F19985.6080705@stats.uwo.ca>
On Fri, Apr 24, 2009 at 5:50 AM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
> Toby wrote:
>>
>> I'm trying to figure out how I can get a generalized 2D
>> list/array/matrix/whatever
>> working. ?Seems I can't figure out how to make the variables the right
>> type. ?I
>> always seem to get some sort of error... out of bounds, wrong type, wrong
>> dim, etc.
>> Very confused... :)
>>
>> x[["some label", "some other index"]] <- 3
>> x[["some other label", "something else"]] <- 4
>>
>> I don't know the indexes/label ahead of time... they get generated... ?Any
>> thoughts?
>>
>
> What you have there is not legal syntax, but this would be:
It isn't?
a <- as.list(1:4)
dim(a) <- c(2, 2)
rownames(a) <- c("a", "b")
colnames(a) <- c("c", "d")
a[["a", "d"]]
Hadley
--
http://had.co.nz/