[R] Lists

Linlin Yan yanlinlin82 at gmail.com
Sat Jul 25 11:30:23 CEST 2009


How about like this:

for (i in seq_along(a)) {
  result <- as.list(a[1:i])
  cat("iterator", i, ":\n")
  print(result)
}

On Sat, Jul 25, 2009 at 6:48 AM, Alberto Lora M<albertoloram at gmail.com> wrote:
> Hi Everybody
>
> I have the following problem
>
> suppose that we
>
> a<-c("uno","dos","tres")
>
> I am working with a while cycle and the idea is in each iteration adding an
> item to a list
>
> In the first iteration the resultshould be:
> [[1]]
> [1] "uno"
>
> In the second
> [[1]]
> [1] "uno"
> [[2]]
> [1] "dos"
>
> And the final result
> [[1]]
> [1] "uno"
> [[2]]
> [1] "dos"
> [[3]]
> [1] "tres"
>
> How can I do that
> Thx again
> --
> Alberto
>
>        [[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.
>




More information about the R-help mailing list