[R] lapply?
Uwe Ligges
ligges at statistik.uni-dortmund.de
Sat Aug 19 16:31:25 CEST 2006
eugene dalt wrote:
> 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])
>
> }
Please do not cross-post!
lapply(testv, rep, x = 5)
Uwe Ligges
> Thanks in Advance. - Eugene
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
More information about the R-help
mailing list