| To: | s-news@lists.biostat.wustl.edu |
|---|---|
| Subject: | simple list question |
| From: | Dave Evens <devens8765@yahoo.com> |
| Date: | Wed, 22 Jun 2005 06:08:56 -0700 (PDT) |
| Domainkey-signature: | a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=toq0iAokTI+aJVB15tsxQ4+yje3A5Mg1XwCYJ4EK/MPCCN19CgP6k8FgEfiOXweGqcdfmqHCWk7Q89vSNXjYKaBOIICWm3NvtyJ1qwvkv+b6vthuEDPdr1k6RRfHxk0kCBv0yrUjqb8unf+AobOnwGHSrcnBUnWtszlheqSSkkQ= ; |
Dear all,
My problem involves naming elements of list within a
list using lapply. For example, if I have a list of
lists of matrices
x <- lapply(1:5, function(k) {lapply(1:k, function(i,
k) {matrix(rnorm(i*i, 1*k, 1), nrow=i, ncol=i)}, k)})
I would like to name the only element in the first
list "A", the elements in the second list "A" and "B"
etc
I thought the following would work - but it doesn't
change the names in x
lapply(1:5, function(k, list.mat)
{return(names(list.mat[[k]]) <- LETTERS[1:k])}, x)
also
names(x) <- lapply(1:5, function(k, list.mat)
{return(names(list.mat[[k]]) <- LETTERS[1:k])}, x)
doesn't work.
How can I label the names in x using lapply rather
than a for loop?
Thanks in advance for any help.
Dave
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: Permuting a data frame, Ernst Linder |
|---|---|
| Next by Date: | AR for short, not equally spaced TS, Xao Ping |
| Previous by Thread: | Course***R/S System: Advanced Programming***July 2005 at 3 locations, elvis |
| Next by Thread: | AR for short, not equally spaced TS, Xao Ping |
| Indexes: | [Date] [Thread] [Top] [All Lists] |