Thank you. that was very easy. 
-srini

--- On Thu, 8/11/11, R. Michael Weylandt <michael.weylandt@gmail.com> wrote:

From: R. Michael Weylandt <michael.weylandt@gmail.com>
Subject: Re: [R] help with loops
To: "Srinivas Iyyer" <srini_iyyer_bio@yahoo.com>
Cc: r-help@r-project.org
Date: Thursday, August 11, 2011, 12:49 PM

unlist()

Michael Weylandt

On Thu, Aug 11, 2011 at 12:46 PM, Srinivas Iyyer <srini_iyyer_bio@yahoo.com> wrote:


hi I need help with list object.



I have a list object



> a <- c('apple','orange','grape')

> b <- c('car','truck','jeep')

> c <- list(a,b)

> names(c) <- c('fruit','vehicle')

> c

$fruit

[1] "apple"  "orange" "grape"



$vehicle

[1] "car"   "truck" "jeep"





I want to write all the elements of this list in one object 'z'.



>z

[1] "apple"  "orange" "grape" "car"   "truck" "jeep"



How can I write the elements of c to z

I tried using a for loop. Could any one help me please. thanks





> z <- ''

> for (i in 1:length(c)){

+ k <- c[[i]]

+ z <- c(z,k)

+ return(z)}

Error: no function to return from, jumping to top level

>





Thank you.

srini



______________________________________________

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.




	[[alternative HTML version deleted]]

