[R] Generalized 2D list/array/whatever?
hadley wickham
h.wickham at gmail.com
Fri Apr 24 14:48:53 CEST 2009
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/
More information about the R-help
mailing list