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
______________________________________________
[email protected] 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.