Permalink
Browse files

Fix typo that was causing a major slow down

  • Loading branch information...
hadley committed Mar 19, 2009
1 parent 60f501b commit 2fab5d5c4ee0751d7c51f40a68e8deb01b54ce80
Showing with 5 additions and 5 deletions.
  1. +1 −0 NEWS
  2. +4 −5 R/ply-list.r
View
1 NEWS
@@ -2,6 +2,7 @@ plyr 0.1.6 (2008-XX-XX) ---------------------------------------------------
* use list names where present
* failwith now accepts a function name, as well as a function itself
+* fix typo that was causing a 50% speed penalty for d*ply
plyr 0.1.5 (2008-02-23) ---------------------------------------------------
View
@@ -26,18 +26,17 @@
#X llply(x, mean)
#X llply(x, quantile, probs = 1:3/4)
llply <- function(.data, .fun = NULL, ..., .progress = "none") {
- pieces <- if (inherits(data, "split")) .data else as.list(.data)
+ pieces <- if (inherits(.data, "split")) .data else as.list(.data)
if (is.null(.fun)) return(pieces)
- if (length(pieces) == 0) return(list())
+ n <- length(pieces)
+ if (n == 0) return(list())
if (is.character(.fun)) .fun <- match.fun(.fun)
if (!is.function(.fun)) stop(".fun is not a function.")
progress <- create_progress_bar(.progress)
-
- progress$init(length(pieces))
+ progress$init(n)
- n <- length(pieces)
result <- vector("list", n)
for(i in seq_len(n)) {

0 comments on commit 2fab5d5

Please sign in to comment.