Re: [R] rbinding some elements from a list and obtain another list

2013-04-30 Thread De Castro Pascual, Montserrat
Hi David,

Sorry if I have explain me wrong!
Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)
I know that this is a malformed command, only was a fast way to descrive
mylist.

Thank you!

-Mensaje original-
De: David Winsemius [mailto:dwinsem...@comcast.net]
Enviado el: lunes, 29 de abril de 2013 17:47
Para: De Castro Pascual, Montserrat
CC: r-help@r-project.org
Asunto: Re: [R] rbinding some elements from a list and obtain another list


On Apr 29, 2013, at 6:54 AM, De Castro Pascual, Montserrat wrote:

> Hi everybody,
>
>
>
> I have a list, where every element of this list is a data frame.
>
>
>
> An example:
>
>
>
> Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)

I'm looking at this apparently malformed command and wondering if that is
the root of all your problems. Do you know how to make a simple successful
example of a list of dataframes?

--
David.

> I want to rbind some elements of this list.
>
> As an example:
>
>
>
> Output<-list(AB=data.frame, CD=data.frame)
>
>
>
> Where
>
> AB=rbind(A,B)
>
> CD=rbind(C,D)
>
>
>
>
>
> I’ve tried:
>
>
>
> f<-function(x){
>
>  for (i in seq(1,length(names(x)),2)){
>
>aa<-do.call(rbind,x[i:i+1])
>
>aa
>
>  }}
>
> bb<-f(mylist)
>
>
>
> or
>
>
>
> f<-function(x){
>
>  for (i in seq(1,length(names(x)),2)){
>
>aa[i]<-do.call(rbind,x[i:i+1])
>
>list(aa[i])
>
>}}
>
> bb<-f (mylist)
>
>
>
> but it doesn’t works
>
>
>
> f<-function(x){
>
> +   for (i in seq(1,length(names(x)),2)){
>
> + aa<-do.call(rbind,x[i:i+1])
>
> + aa
>
> +   }}
>
>> bb<-f(mylist)
>
>> bb
>
> NULL
>
>> f<-function(x){
>
> +   for (i in seq(1,length(names(x)),2)){
>
> + aa<-do.call(rbind,x[i:i+1])
>
> + aa
>
> +   }}
>
>> bb<-f(mylist)
>
>>
>
>> f<-function(x){
>
> +   for (i in seq(1,length(names(x)),2)){
>
> + aa[i]<-do.call(rbind,x[i:i+1])
>
> + list(aa[i])
>
> +   }}
>
>> bb<-f(mylist)
>
> Mensajes de aviso perdidos
>
> 1: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
> del reemplazo
>
> 2: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
> del reemplazo
>
> 3: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
> del reemplazo
>
> 4: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
> del reemplazo
>
> 5: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
> del reemplazo
>
> 6: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
> del reemplazo
>
>
>
>
>
> Thanks!
>
>
>
> Montserrat
>
>
>
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@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.

David Winsemius
Alameda, CA, USA

__
R-help@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.


Re: [R] rbinding some elements from a list and obtain another list

2013-04-30 Thread De Castro Pascual, Montserrat
Wow! It's true!!!

Many thanks!!!

montserrat

-Mensaje original-
De: MacQueen, Don [mailto:macque...@llnl.gov]
Enviado el: lunes, 29 de abril de 2013 22:39
Para: De Castro Pascual, Montserrat; r-help@r-project.org
Asunto: Re: [R] rbinding some elements from a list and obtain another list

In addition to the other responses, consider this:

> i <- 3
> i:i+1
[1] 4
> i:(i+1)
[1] 3 4

-Don


--
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 4/29/13 6:54 AM, "De Castro Pascual, Montserrat" 
wrote:

>Hi everybody,
>
>
>
>I have a list, where every element of this list is a data frame.
>
>
>
>An example:
>
>
>
>Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)
>
>
>
>I want to rbind some elements of this list.
>
>As an example:
>
>
>
>Output<-list(AB=data.frame, CD=data.frame)
>
>
>
>Where
>
>AB=rbind(A,B)
>
>CD=rbind(C,D)
>
>
>
>
>
>I¹ve tried:
>
>
>
>f<-function(x){
>
>  for (i in seq(1,length(names(x)),2)){
>
>aa<-do.call(rbind,x[i:i+1])
>
>aa
>
>  }}
>
>bb<-f(mylist)
>
>
>
>or
>
>
>
>f<-function(x){
>
>  for (i in seq(1,length(names(x)),2)){
>
>aa[i]<-do.call(rbind,x[i:i+1])
>
>list(aa[i])
>
>}}
>
>bb<-f (mylist)
>
>
>
>but it doesn¹t works
>
>
>
>f<-function(x){
>
>+   for (i in seq(1,length(names(x)),2)){
>
>+ aa<-do.call(rbind,x[i:i+1])
>
>+ aa
>
>+   }}
>
>> bb<-f(mylist)
>
>> bb
>
>NULL
>
>> f<-function(x){
>
>+   for (i in seq(1,length(names(x)),2)){
>
>+ aa<-do.call(rbind,x[i:i+1])
>
>+ aa
>
>+   }}
>
>> bb<-f(mylist)
>
>>
>
>> f<-function(x){
>
>+   for (i in seq(1,length(names(x)),2)){
>
>+ aa[i]<-do.call(rbind,x[i:i+1])
>
>+ list(aa[i])
>
>+   }}
>
>> bb<-f(mylist)
>
>Mensajes de aviso perdidos
>
>1: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
>del reemplazo
>
>2: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
>del reemplazo
>
>3: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
>del reemplazo
>
>4: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
>del reemplazo
>
>5: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
>del reemplazo
>
>6: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud
>del reemplazo
>
>
>
>
>
>Thanks!
>
>
>
>Montserrat
>
>
>
>
>   [[alternative HTML version deleted]]
>

__
R-help@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.


Re: [R] rbinding some elements from a list and obtain another list

2013-04-30 Thread De Castro Pascual, Montserrat
BINGO!!!
Many thanks arun!
You are a genious!!!

montserrat

-Mensaje original-
De: arun [mailto:smartpink...@yahoo.com]
Enviado el: lunes, 29 de abril de 2013 18:33
Para: De Castro Pascual, Montserrat
CC: R help
Asunto: Re: [R] rbinding some elements from a list and obtain another list

Hi,
Try this:
set.seed(24)
 lst1<-lapply(1:4,function(x) 
as.data.frame(matrix(sample(1:20,20,replace=TRUE),ncol=5)))
 names(lst1)<- LETTERS[1:4]

res<-lapply(list(c("A","B"),c("C","D")), function(x) do.call(rbind,lst1[x]))
 res
#[[1]]
 #   V1 V2 V3 V4 V5
#A.1  6 14 17 14  4
#A.2  5 19  6 14  1
#A.3 15  6 13  7 11
#A.4 11 16  8 19  3
#B.1  2  5 13  8 15
#B.2 12 14  1  3 13
#B.3 15  2  7 19 14
#B.4  3 12  5  5 20
#
#[[2]]
 #   V1 V2 V3 V4 V5
#C.1 10  1  6 10 10
#C.2  8  2  7 15  6
#C.3  6  8 10 11  4
#C.4  5  8 18 20  3
#D.1 10 15 15  1 12
#D.2  5  7 10 20 17
#D.3  6 19  3 13  1
#D.4  3 20  5  7 15
A.K.





- Original Message -
From: "De Castro Pascual, Montserrat" 
To: r-help@r-project.org
Cc:
Sent: Monday, April 29, 2013 9:54 AM
Subject: [R] rbinding some elements from a list and obtain another list

Hi everybody,



I have a list, where every element of this list is a data frame.



An example:



Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)



I want to rbind some elements of this list.

As an example:



Output<-list(AB=data.frame, CD=data.frame)



Where

AB=rbind(A,B)

CD=rbind(C,D)





I’ve tried:



f<-function(x){

  for (i in seq(1,length(names(x)),2)){

aa<-do.call(rbind,x[i:i+1])

aa

  }}

bb<-f(mylist)



or



f<-function(x){

  for (i in seq(1,length(names(x)),2)){

aa[i]<-do.call(rbind,x[i:i+1])

list(aa[i])

}}

bb<-f (mylist)



but it doesn’t works



f<-function(x){

+   for (i in seq(1,length(names(x)),2)){

+ aa<-do.call(rbind,x[i:i+1])

+ aa

+   }}

> bb<-f(mylist)

> bb

NULL

> f<-function(x){

+   for (i in seq(1,length(names(x)),2)){

+ aa<-do.call(rbind,x[i:i+1])

+ aa

+   }}

> bb<-f(mylist)

>

> f<-function(x){

+   for (i in seq(1,length(names(x)),2)){

+ aa[i]<-do.call(rbind,x[i:i+1])

+ list(aa[i])

+   }}

> bb<-f(mylist)

Mensajes de aviso perdidos

1: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo

2: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo

3: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo

4: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo

5: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo

6: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del 
reemplazo





Thanks!



Montserrat




[[alternative HTML version deleted]]


__
R-help@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.

__
R-help@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.


Re: [R] rbinding some elements from a list and obtain another list

2013-04-29 Thread MacQueen, Don
In addition to the other responses, consider this:

> i <- 3
> i:i+1
[1] 4
> i:(i+1)
[1] 3 4

-Don


-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 4/29/13 6:54 AM, "De Castro Pascual, Montserrat" 
wrote:

>Hi everybody,
>
>
>
>I have a list, where every element of this list is a data frame.
>
>
>
>An example:
>
>
>
>Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)
>
>
>
>I want to rbind some elements of this list.
>
>As an example:
>
>
>
>Output<-list(AB=data.frame, CD=data.frame)
>
>
>
>Where
>
>AB=rbind(A,B)
>
>CD=rbind(C,D)
>
>
>
>
>
>I¹ve tried:
>
>
>
>f<-function(x){
>
>  for (i in seq(1,length(names(x)),2)){
>
>aa<-do.call(rbind,x[i:i+1])
>
>aa
>
>  }}
>
>bb<-f(mylist)
>
>
>
>or
>
>
>
>f<-function(x){
>
>  for (i in seq(1,length(names(x)),2)){
>
>aa[i]<-do.call(rbind,x[i:i+1])
>
>list(aa[i])
>
>}}
>
>bb<-f (mylist)
>
>
>
>but it doesn¹t works
>
>
>
>f<-function(x){
>
>+   for (i in seq(1,length(names(x)),2)){
>
>+ aa<-do.call(rbind,x[i:i+1])
>
>+ aa
>
>+   }}
>
>> bb<-f(mylist)
>
>> bb
>
>NULL
>
>> f<-function(x){
>
>+   for (i in seq(1,length(names(x)),2)){
>
>+ aa<-do.call(rbind,x[i:i+1])
>
>+ aa
>
>+   }}
>
>> bb<-f(mylist)
>
>>
>
>> f<-function(x){
>
>+   for (i in seq(1,length(names(x)),2)){
>
>+ aa[i]<-do.call(rbind,x[i:i+1])
>
>+ list(aa[i])
>
>+   }}
>
>> bb<-f(mylist)
>
>Mensajes de aviso perdidos
>
>1: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud del
>reemplazo
>
>2: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud del
>reemplazo
>
>3: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud del
>reemplazo
>
>4: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud del
>reemplazo
>
>5: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud del
>reemplazo
>
>6: In aa[i] <- do.call(rbind, x[i:i + 1]) :
>
>  número de items para para sustituir no es un múltiplo de la longitud del
>reemplazo
>
>
>
>
>
>Thanks!
>
>
>
>Montserrat
>
>
>
>
>   [[alternative HTML version deleted]]
>

__
R-help@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.


Re: [R] rbinding some elements from a list and obtain another list

2013-04-29 Thread arun
Hi,
Try this:
set.seed(24)
 lst1<-lapply(1:4,function(x) 
as.data.frame(matrix(sample(1:20,20,replace=TRUE),ncol=5)))
 names(lst1)<- LETTERS[1:4]

res<-lapply(list(c("A","B"),c("C","D")), function(x) do.call(rbind,lst1[x]))
 res
#[[1]]
 #   V1 V2 V3 V4 V5
#A.1  6 14 17 14  4
#A.2  5 19  6 14  1
#A.3 15  6 13  7 11
#A.4 11 16  8 19  3
#B.1  2  5 13  8 15
#B.2 12 14  1  3 13
#B.3 15  2  7 19 14
#B.4  3 12  5  5 20
#
#[[2]]
 #   V1 V2 V3 V4 V5
#C.1 10  1  6 10 10
#C.2  8  2  7 15  6
#C.3  6  8 10 11  4
#C.4  5  8 18 20  3
#D.1 10 15 15  1 12
#D.2  5  7 10 20 17
#D.3  6 19  3 13  1
#D.4  3 20  5  7 15
A.K.





- Original Message -
From: "De Castro Pascual, Montserrat" 
To: r-help@r-project.org
Cc: 
Sent: Monday, April 29, 2013 9:54 AM
Subject: [R] rbinding some elements from a list and obtain another list

Hi everybody,



I have a list, where every element of this list is a data frame.



An example:



Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)



I want to rbind some elements of this list.

As an example:



Output<-list(AB=data.frame, CD=data.frame)



Where

AB=rbind(A,B)

CD=rbind(C,D)





I’ve tried:



f<-function(x){

  for (i in seq(1,length(names(x)),2)){

    aa<-do.call(rbind,x[i:i+1])

    aa

  }}

bb<-f(mylist)



or



f<-function(x){

  for (i in seq(1,length(names(x)),2)){

    aa[i]<-do.call(rbind,x[i:i+1])

    list(aa[i])

    }}

bb<-f (mylist)



but it doesn’t works



f<-function(x){

+   for (i in seq(1,length(names(x)),2)){

+     aa<-do.call(rbind,x[i:i+1])

+     aa

+   }}

> bb<-f(mylist)

> bb

NULL

> f<-function(x){

+   for (i in seq(1,length(names(x)),2)){

+     aa<-do.call(rbind,x[i:i+1])

+     aa

+   }}

> bb<-f(mylist)

>

> f<-function(x){

+   for (i in seq(1,length(names(x)),2)){

+     aa[i]<-do.call(rbind,x[i:i+1])

+     list(aa[i])

+   }}

> bb<-f(mylist)

Mensajes de aviso perdidos

1: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del
reemplazo

2: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del
reemplazo

3: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del
reemplazo

4: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del
reemplazo

5: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del
reemplazo

6: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del
reemplazo





Thanks!



Montserrat




    [[alternative HTML version deleted]]


__
R-help@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.


__
R-help@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.


Re: [R] rbinding some elements from a list and obtain another list

2013-04-29 Thread David Winsemius

On Apr 29, 2013, at 6:54 AM, De Castro Pascual, Montserrat wrote:

> Hi everybody,
> 
> 
> 
> I have a list, where every element of this list is a data frame.
> 
> 
> 
> An example:
> 
> 
> 
> Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)

I'm looking at this apparently malformed command and wondering if that is the 
root of all your problems. Do you know how to make a simple successful example 
of a list of dataframes?

-- 
David.

> I want to rbind some elements of this list.
> 
> As an example:
> 
> 
> 
> Output<-list(AB=data.frame, CD=data.frame)
> 
> 
> 
> Where
> 
> AB=rbind(A,B)
> 
> CD=rbind(C,D)
> 
> 
> 
> 
> 
> I’ve tried:
> 
> 
> 
> f<-function(x){
> 
>  for (i in seq(1,length(names(x)),2)){
> 
>aa<-do.call(rbind,x[i:i+1])
> 
>aa
> 
>  }}
> 
> bb<-f(mylist)
> 
> 
> 
> or
> 
> 
> 
> f<-function(x){
> 
>  for (i in seq(1,length(names(x)),2)){
> 
>aa[i]<-do.call(rbind,x[i:i+1])
> 
>list(aa[i])
> 
>}}
> 
> bb<-f (mylist)
> 
> 
> 
> but it doesn’t works
> 
> 
> 
> f<-function(x){
> 
> +   for (i in seq(1,length(names(x)),2)){
> 
> + aa<-do.call(rbind,x[i:i+1])
> 
> + aa
> 
> +   }}
> 
>> bb<-f(mylist)
> 
>> bb
> 
> NULL
> 
>> f<-function(x){
> 
> +   for (i in seq(1,length(names(x)),2)){
> 
> + aa<-do.call(rbind,x[i:i+1])
> 
> + aa
> 
> +   }}
> 
>> bb<-f(mylist)
> 
>> 
> 
>> f<-function(x){
> 
> +   for (i in seq(1,length(names(x)),2)){
> 
> + aa[i]<-do.call(rbind,x[i:i+1])
> 
> + list(aa[i])
> 
> +   }}
> 
>> bb<-f(mylist)
> 
> Mensajes de aviso perdidos
> 
> 1: In aa[i] <- do.call(rbind, x[i:i + 1]) :
> 
>  número de items para para sustituir no es un múltiplo de la longitud del
> reemplazo
> 
> 2: In aa[i] <- do.call(rbind, x[i:i + 1]) :
> 
>  número de items para para sustituir no es un múltiplo de la longitud del
> reemplazo
> 
> 3: In aa[i] <- do.call(rbind, x[i:i + 1]) :
> 
>  número de items para para sustituir no es un múltiplo de la longitud del
> reemplazo
> 
> 4: In aa[i] <- do.call(rbind, x[i:i + 1]) :
> 
>  número de items para para sustituir no es un múltiplo de la longitud del
> reemplazo
> 
> 5: In aa[i] <- do.call(rbind, x[i:i + 1]) :
> 
>  número de items para para sustituir no es un múltiplo de la longitud del
> reemplazo
> 
> 6: In aa[i] <- do.call(rbind, x[i:i + 1]) :
> 
>  número de items para para sustituir no es un múltiplo de la longitud del
> reemplazo
> 
> 
> 
> 
> 
> Thanks!
> 
> 
> 
> Montserrat
> 
> 
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@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.

David Winsemius
Alameda, CA, USA

__
R-help@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.


[R] rbinding some elements from a list and obtain another list

2013-04-29 Thread De Castro Pascual, Montserrat
Hi everybody,



I have a list, where every element of this list is a data frame.



An example:



Mylist<-list(A=data.frame, B=data.frame, C=data.frame, D=data.frame)



I want to rbind some elements of this list.

As an example:



Output<-list(AB=data.frame, CD=data.frame)



Where

AB=rbind(A,B)

CD=rbind(C,D)





I’ve tried:



f<-function(x){

  for (i in seq(1,length(names(x)),2)){

aa<-do.call(rbind,x[i:i+1])

aa

  }}

bb<-f(mylist)



or



f<-function(x){

  for (i in seq(1,length(names(x)),2)){

aa[i]<-do.call(rbind,x[i:i+1])

list(aa[i])

}}

bb<-f (mylist)



but it doesn’t works



f<-function(x){

+   for (i in seq(1,length(names(x)),2)){

+ aa<-do.call(rbind,x[i:i+1])

+ aa

+   }}

> bb<-f(mylist)

> bb

NULL

> f<-function(x){

+   for (i in seq(1,length(names(x)),2)){

+ aa<-do.call(rbind,x[i:i+1])

+ aa

+   }}

> bb<-f(mylist)

>

> f<-function(x){

+   for (i in seq(1,length(names(x)),2)){

+ aa[i]<-do.call(rbind,x[i:i+1])

+ list(aa[i])

+   }}

> bb<-f(mylist)

Mensajes de aviso perdidos

1: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del
reemplazo

2: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del
reemplazo

3: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del
reemplazo

4: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del
reemplazo

5: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del
reemplazo

6: In aa[i] <- do.call(rbind, x[i:i + 1]) :

  número de items para para sustituir no es un múltiplo de la longitud del
reemplazo





Thanks!



Montserrat




[[alternative HTML version deleted]]

__
R-help@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.