Re: [R] Repeating values in a list

2010-09-18 Thread Bill.Venables
AM To: R (r-help@R-project.org) Subject: [R] Repeating values in a list 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 <

Re: [R] Repeating values in a list

2010-09-18 Thread Derek Ogle
e,c(1,1,2)) $a [1] 7 $b [1] 3 $c [1] 1 1 From: Dennis Murphy [mailto:djmu...@gmail.com] Sent: Saturday, September 18, 2010 8:25 PM To: Derek Ogle Cc: R (r-help@R-project.org) Subject: Re: [R] Repeating values in a list Hi: How about > have <- list(a=7,b=3,c=1) > lapply(have, rep, 2

Re: [R] Repeating values in a list

2010-09-18 Thread Dennis Murphy
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 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 > >

[R] Repeating values in a list

2010-09-18 Thread Derek Ogle
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 othe