[R] complexity of operations in R
Hadley Wickham
hadley at rice.edu
Thu Jul 19 17:50:29 CEST 2012
On Thu, Jul 19, 2012 at 8:02 AM, Jan van der Laan <rhelp at eoos.dds.nl> wrote:
> Johan,
>
> Your 'list' and 'array doubling' code can be written much more efficient.
>
> The following function is faster than your g and easier to read:
>
> g2 <- function(dotot) {
> v <- list()
> for (i in seq_len(dotot)) {
> v[[i]] <- FALSE
> }
> }
Except that you don't need to pre-allocate lists...
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
More information about the R-help
mailing list