[R] List funtion

ruipbarradas at sapo.pt ruipbarradas at sapo.pt
Tue Mar 15 13:41:36 CET 2016


Hello,

rep() is vectorized so you can do

rep (my_list, 2:3)

Hope this helps,

Rui Barradas
 

Citando André Luis Neves <andrluis at ualberta.ca>:

> Dear,
>
> I have the following data:
>
> v1 <- c(8,4,9,12)
> v2 <- c(7, 8, 11)
> my_list <- list(v1,v2)
> rep (my_list,3)
>
> My question is how I can modify my command line to create a list  
> called my_list
> containing two copies of the first vector (v1) and three copies of the vector
> 2 (v2).
>
> The above command line creates 3 copies of both vectors, but I would like
> to create 2 copies of one and 3 from the other, and return these results
> within my_list object.
>
> Thanks,
>
> Andre
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide  
> http://www.R-project.org/posting-guide.htmland provide commented,  
> minimal, self-contained, reproducible code.

 

	[[alternative HTML version deleted]]



More information about the R-help mailing list