[R] List funtion

Mohammad Tanvir Ahamed mashranga at yahoo.com
Tue Mar 15 13:49:39 CET 2016


> v3<-list(rep(list(v1),2),rep(list(v2),3)) 
> v3 
[[1]] 
[[1]][[1]] 
[1]  8  4  9 12 

[[1]][[2]] 
[1]  8  4  9 12 


[[2]] 
[[2]][[1]] 
[1]  7  8 11 

[[2]][[2]] 
[1]  7  8 11 

[[2]][[3]] 
[1]  7  8 11

if you want to track each list category. 
 Tanvir Ahamed 
Göteborg, Sweden   |  mashranga at yahoo.com 


----- Original Message -----
From: André Luis Neves <andrluis at ualberta.ca>
To: r-help at r-project.org
Sent: Monday, 14 March 2016, 23:20
Subject: [R] List funtion

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.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list