On 2012-07-02 15:16, Spencer Maynes wrote:
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
suggestions?

lapply( b, function(x) x[] <- d )

Peter Ehlers

______________________________________________
R-help@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.

Reply via email to