Re: [R] Multiply list objects

2011-06-17 Thread Uwe Ligges
I still do not get the point for what task this expansion of data may be useful, by I guess you want (in this case probably very inefficient, but other can work out how to improve if interested) to insert after k <- lapply(h, function (x) x*0) the lines: for(i in seq_along(k)){ temp <- re

Re: [R] Multiply list objects

2011-06-17 Thread Mathijs de Vaan
Sorry, forgot to quote: Hi, I am trying to use the objects from the list below to create more objects. For each year in h I am trying to create as many objects as there are B's keeping only the values of B. Example for 1999: $`1999`$`8025` B B 8025 8026 8027 8028 8029 802511

Re: [R] Multiply list objects

2011-06-17 Thread Uwe Ligges
Since this example is not reproducible (and you have not quuoted any former code) I can only give advice "in principle": 1. Never use 1:length(x) since this will seriously fail if x is a length 0 object. Instead, use seq_along(x) 2. If k is a list, then you probably want to use doubled brackets

Re: [R] Multiply list objects

2011-06-16 Thread mdvaan
I am still thinking about this problem. The solution could look something like this (it's net yet working): k<-lapply(h, function (x) x*0) # I keep the same format as h, but set all values to 0 years<-c(1997:1999) # I define the years for (t in 1:length(years)) { year = as.characte

[R] Multiply list objects

2011-06-13 Thread mdvaan
Hi, I am trying to use the objects from the list below to create more objects. For each year in h I am trying to create as many objects as there are B's keeping only the values of B. Example for 1999: $`1999`$`8025` B B 8025 8026 8027 8028 8029 802511100 8026