| To: | s-news@lists.biostat.wustl.edu |
|---|---|
| Subject: | List question |
| From: | Dave Evens <devens8765@yahoo.com> |
| Date: | Wed, 17 Aug 2005 06:38:36 -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=Q1Fj6NmazWhSvMBeB3Df3nmrYUVLTl+JIJ9I/w4Jc7vlIDPeRlCLHUgxDR2bYc1cR7TGtWU/iy4qZmZUehjdcc84ocMf6DEi2NsLbeKIDDKTY1AZeK4PNmTAKpB3Lzn8BTEWANGtA3cSLQY83BVKGumrQCf36Nwk7JTQrkj9suw= ; |
Dear all,
My query involves a list. For example, suppose I have
a list x
x <- list(list(rpois(100,2), list(LETTERS[1:20]),
list()),
list(rpois(150,2), list(LETTERS[1:12]),
list()),
list(rpois(200,2), list(LETTERS[1:19]),
list()))
and I want to replace the empty list in each sub-list
of x, this is easy using the for-loop
for(k in 1:length(x)) x[[k]][[3]] <- matrix(rnorm(100,
10, 2), 10,10)
but how do I the equivalent of this using the lapply
command?
This is the syntax of the lapply command
lapply(1:length(x), function(k) matrix(rnorm(100, 10,
2), 10,10))
but how do I get it in x[[k]][[3]]?
I've tried using the assign command but it doesn't
appear to work.
Thanks for any help in advance.
Dave
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Problem importing data, stephane . g . zebouni |
|---|---|
| Next by Date: | Re: List question, Prof Brian Ripley |
| Previous by Thread: | Problem importing data, stephane . g . zebouni |
| Next by Thread: | Re: List question, Prof Brian Ripley |
| Indexes: | [Date] [Thread] [Top] [All Lists] |