Eugene,
Try

> 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"                                             
                                                              
                      <[EMAIL PROTECTED]>           To:       [EMAIL 
PROTECTED], [email protected]                     
                      Sent by:                         cc:                      
                                                              
                      [EMAIL PROTECTED]        Subject:  [S] lapply?            
                                                      
                      t.wustl.edu                                               
                                                              
                                                                                
                                                              
                                                                                
                                                              
                      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
http://mail.yahoo.com
--------------------------------------------------------------------
This message was distributed by [EMAIL PROTECTED]  To
...(s-news.. clipped)...

______________________________________________
[email protected] 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