Hello y'll,
thanks a lot for your hints. The easiest solution was the one from
Jim, using "[[" whose true function
I did not realize fully.
About apply and the sorts: I agree that if you get them to work the
are much faster and yield nice, compact code. But I have never fully
understood the inner
Perhaps this will help:
#Data Example
gnuff<-list()
gnuff$IHD$LE<-66
gnuff$LUNG$LE <-55
#This is the list, where I collect data for different diseases at the
#second level of the list
#Now I want to do calcualtions just for these two diseases and the
#sub-list "LE" within these diseases
nam <-
Or perhaps:
lapply(gnuff, "[[", "LE")
On Fri, Jan 30, 2009 at 12:35 PM, Patrick Burns
wrote:
> A rule of thumb is that if the solution seems a lot
> harder than the task, there is probably a better
> approach. I think you want something like:
>
> lapply(gnuff[nam], function(x) x$LE)
>
>
> Patr
A rule of thumb is that if the solution seems a lot
harder than the task, there is probably a better
approach. I think you want something like:
lapply(gnuff[nam], function(x) x$LE)
Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of "The R Inferno" and "
This should do it:
?"[["
> gnuff<-list()
> gnuff$IHD$LE<-66
> gnuff$LUNG$LE <-55
>
>
>
> nam <- c("LUNG","IHD")
>
> x <- numeric(2) # allocate
> for(i in 1:2)
+ x[i] <- gnuff[[nam[i]]]$LE / 2
>
> x
[1] 27.5 33.0
On Fri, Jan 30, 2009 at 12:06 PM, stefan.d...@gmail.com
wrote:
> Hello,
> I have
5 matches
Mail list logo