Re: [R] Bind field of a list

2010-02-19 Thread Philipp Rappold

is this what you're looking for?

test - data.frame(a=c(x,v),b=c(n,m))
test

statquant wrote:

Hello all
I am new in R and so easy stuff are difficult...
let say that I have a list 
test - list(a=c(x,v),b=c(n,m))

how can I without a loop get test$a bind with test$b (obviously in real life
their would be many fields)

Cheers and thanks


__
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] Bind field of a list

2010-02-19 Thread statquant

Hello,
Thank you but I think not what I would like to get as an answer is the list
(x,v,n,m) + what you gave me could work for 2 fields but if I have
200...


What I want is a vectorize way to do 
bindlists - function(x){
output = c();
for (i in 1:length(x))
{
output = c(output,x[[i]])
}
return(output)
}

Regards
-- 
View this message in context: 
http://n4.nabble.com/Bind-field-of-a-list-tp1561676p1561727.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Bind field of a list

2010-02-19 Thread baptiste auguie
Hi,

Try this,

unlist(test)

or

do.call(c, test)

HTH,

baptiste

On 19 February 2010 15:19, statquant colin.uman...@barcap.com wrote:

 Hello all
 I am new in R and so easy stuff are difficult...
 let say that I have a list
 test - list(a=c(x,v),b=c(n,m))
 how can I without a loop get test$a bind with test$b (obviously in real life
 their would be many fields)

 Cheers and thanks
 --
 View this message in context: 
 http://n4.nabble.com/Bind-field-of-a-list-tp1561676p1561676.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 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] Bind field of a list

2010-02-19 Thread David Winsemius


On Feb 19, 2010, at 9:49 AM, statquant wrote:



Hello,
Thank you but I think not what I would like to get as an answer is  
the list
(x,v,n,m) + what you gave me could work for 2 fields but if  
I have

200...


What I want is a vectorize way to do
bindlists - function(x){
output = c();
for (i in 1:length(x))
{
output = c(output,x[[i]])
}
return(output)
}


Instead try:

c( sapply(test, [) )

The inner (implicit) loop gets you a matrix and the outer c() turns it  
into the requested vector. You could have coerced the matrix to vector  
with as.vector, too.


Regards
--
View this message in context: 
http://n4.nabble.com/Bind-field-of-a-list-tp1561676p1561727.html
Sent from the R help mailing list archive at Nabble.com.

__
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, MD
Heritage Laboratories
West Hartford, CT

__
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] Bind field of a list

2010-02-19 Thread statquant

Bravo baptiste it works
what does do.call do exactly ??
-- 
View this message in context: 
http://n4.nabble.com/Bind-field-of-a-list-tp1561676p1561745.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Bind field of a list

2010-02-19 Thread Colin.Umansky
Hello, 
Thank you but I think not what I would like to get as an answer is the list 
(x,v,n,m) + what you gave me could work for 2 fields but if I have 
200...


What I want is a vectorize way to do 
bindlists - function(x){
output = c();
for (i in 1:length(x))
{
output = c(output,x[[i]])
}
return(output)
}

Regards

-Original Message-
From: Philipp Rappold [mailto:philipp.rapp...@gmail.com] 
Sent: 19 February 2010 14:31
To: Umansky, Colin: EDG (LDN)
Cc: r-help@r-project.org
Subject: Re: [R] Bind field of a list

is this what you're looking for?

test - data.frame(a=c(x,v),b=c(n,m))
test

statquant wrote:
 Hello all
 I am new in R and so easy stuff are difficult...
 let say that I have a list 
 test - list(a=c(x,v),b=c(n,m))
 how can I without a loop get test$a bind with test$b (obviously in real life
 their would be many fields)
 
 Cheers and thanks
___

This e-mail may contain information that is confidential, privileged or 
otherwise protected from disclosure. If you are not an intended recipient of 
this e-mail, do not duplicate or redistribute it by any means. Please delete it 
and any attachments and notify the sender that you have received it in error. 
Unless specifically indicated, this e-mail is not an offer to buy or sell or a 
solicitation to buy or sell any securities, investment products or other 
financial product or service, an official confirmation of any transaction, or 
an official statement of Barclays. Any views or opinions presented are solely 
those of the author and do not necessarily represent those of Barclays. This 
e-mail is subject to terms available at the following link: 
www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the 
foregoing.  Barclays Capital is the investment banking division of Barclays 
Bank PLC, a company registered in England (number 1026167) with its registered 
offi!
 ce at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent 
from other members of the Barclays Group.

__
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.