Hi guys,
I have a list of 250 numbers as a result of using the ?by function!
List of 246
$ 0 : num [1:28] 22 11 31...
$ 1 : num [1:15] 12 14 9 ...
..
..
..
- attr(*, "dim")= int 250
- attr(*, "dimnames")=List of 1
The problem is that each list of 250 has different length! I would like to get
the values of each list in a vector like vector_0 = (22,11,31,..), is this
possible?
Thank you in advance,
Christina
[[alternative HTML version deleted]]
Try this:> L <- list(`0` = 1:4, `1` = 2:3)> sum(L$`0`)[1] 10> with(L, sum(`0`))[1] 10> # not recommended tho' this is closest to what you asked for > attach(L) > sum(`0`)[1] 10 On Mon, Sep 28, 2009 at 10:57 AM, Christina Rodemeyer <christinarodemeyer at yahoo.de> wrote:> Hi guys, > > I have a list of 250 numbers as a result of using the ?by function! > List of 246 > ?$ 0?? : num [1:28] 22 11 31... > ?$ 1?? : num [1:15] 12 14 9 ... > .. > .. > .. > ?- attr(*, "dim")= int 250 > ?- attr(*, "dimnames")=List of 1 > > The problem is that each list of 250 has different length! I would like to get the values of each list in a vector like vector_0 = (22,11,31,..), is this possible? > > Thank you in advance, > Christina > > > > > ? ? ? ?[[alternative HTML version deleted]] > > > ______________________________________________ > R-help at 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. > >
Try this:
lapply(names(L), function(l)assign(sprintf('vector_%s', l), L[l],
envir = globalenv()))
ls()
On Mon, Sep 28, 2009 at 11:57 AM, Christina Rodemeyer
<christinarodemeyer at yahoo.de> wrote:> Hi guys,
>
> I have a list of 250 numbers as a result of using the ?by function!
> List of 246
> ?$ 0?? : num [1:28] 22 11 31...
> ?$ 1?? : num [1:15] 12 14 9 ...
> ..
> ..
> ..
> ?- attr(*, "dim")= int 250
> ?- attr(*, "dimnames")=List of 1
>
> The problem is that each list of 250 has different length! I would like to
get the values of each list in a vector like vector_0 = (22,11,31,..), is this
possible?
>
> Thank you in advance,
> Christina
>
>
>
>
> ? ? ? ?[[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at 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.
>
>
--
Henrique Dallazuanna
Curitiba-Paran?-Brasil
25? 25' 40" S 49? 16' 22" O