On Fri, Apr 24, 2009 at 5:50 AM, Duncan Murdoch <murd...@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/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.