[R] Assigning a vector to every element of a list.
smartpink111 at yahoo.com
Tue Jul 3 08:31:36 CEST 2012
If you want to assign a vector to every element of a list,
# if you want to assign each element of vector to each element of list (assuming both have the same lengths),
----- Original Message -----
From: Spencer Maynes <smaynes89 at gmail.com>
To: r-help at r-project.org
Sent: Monday, July 2, 2012 6:16 PM
Subject: [R] Assigning a vector to every element of a list.
I have a vector d of unknown length, and a list b of unknown length. I
would like to replace every element of b with d. Simply writing b<-d does
not work as R tries to fit every element of d to a different element of d,
and b<-rep(d,length(b)) does not work either as it makes a list of
length length(d)*length(b) not a list of length(b). I know how to do this
with a for loop, but I feel that there has to be a more efficient way. Any
[[alternative HTML version deleted]]
R-help at r-project.org mailing list
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