[R] [S] lapply?

Daniel_J_Celta at fpl.com Daniel_J_Celta at fpl.com
Sat Aug 19 21:10:05 CEST 2006


> lapply(c(4,6,7,8), function(x) rep(5, x))

I think this would do what you are trying to do.

Daniel J Celta
Project Valuation - Special Valuations
561 691 7653

                      "eugene dalt"                                                                                                           
                      <eugenedalt at yahoo.com>           To:       s-news at lists.biostat.wustl.edu, r-help at stat.math.ethz.ch                     
                      Sent by:                         cc:                                                                                    
                      s-news-owner at lists.biosta        Subject:  [S] lapply?                                                                  
                      08/19/2006 10:01 AM                                                                                                     

Hi folks,

I would like to know if the following loop can be
rewritten with lapply

list1 <- as.list(0)

testv <- c(4,6,7,8)

for( i in 1:4){

list1[[i]] <- rep(5,testv[i])


Thanks in Advance. - Eugene

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
This message was distributed by s-news at lists.biostat.wustl.edu.  To
...(s-news.. clipped)...

More information about the R-help mailing list