Hi: How about
> have <- list(a=7,b=3,c=1) > lapply(have, rep, 2) $a [1] 7 7 $b [1] 3 3 $c [1] 1 1 HTH, Dennis On Sat, Sep 18, 2010 at 6:19 PM, Derek Ogle <do...@northland.edu> wrote: > I have a list that looks like this ... > > > have <- list(a=7,b=3,c=1) > > have > $a > [1] 7 > > $b > [1] 3 > > $c > [1] 1 > > and I want to have a simple way to change it to the following without > re-typing the values ... > > > desire <- list(a=c(7,7),b=c(3,3),c=c(1,1)) > > desire > $a > [1] 7 7 > > $b > [1] 3 3 > > $c > [1] 1 1 > > In other words, I need to create the list in desire from the list in have. > > In my "real" work the number of items in the list may be more than three > and the number of times to repeat the numbers may be greater than two. > > Thank you in advance for any help you can offer. > > ______________________________________________ > 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. > [[alternative HTML version deleted]] ______________________________________________ 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.