Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor tweaks

  • Loading branch information...
commit 9d99cfc2de65e615729400b468cd540827b48460 1 parent 070d37e
Hadley Wickham authored
Showing with 8 additions and 5 deletions.
  1. +1 −1  R/indexed-list.r
  2. +2 −1  R/ply-list.r
  3. +5 −3 R/simplify.r
2  R/indexed-list.r
View
@@ -18,7 +18,7 @@ indexed_list <- function(env, index) {
length.indexed_list <- function(x) length(x$index)
"[[.indexed_list" <- function(x, i) {
- x$env$data[x$index[[i]], ]
+ x$env$data[x$index[[i]], , drop = FALSE]
}
names.indexed_list <- function(x) names(x$index)
3  R/ply-list.r
View
@@ -40,7 +40,8 @@ llply <- function(.data, .fun = NULL, ..., .progress = "none") {
result <- vector("list", n)
for(i in seq_len(n)) {
- res <- .fun(pieces[[i]], ...)
+ piece <- pieces[[i]]
+ res <- .fun(piece, ...)
if (!is.null(res)) result[[i]] <- res
progress$step()
}
8 R/simplify.r
View
@@ -54,10 +54,12 @@ list_to_array <- function(res, labels = NULL, .drop = FALSE) {
if (all(atomic)) {
# Atomics need to be same size
dlength <- unique.default(llply(res, dims))
- if (length(dlength) != 1) stop("Results must have the same number of dimensions.")
+ if (length(dlength) != 1)
+ stop("Results must have the same number of dimensions.")
dims <- unique(do.call("rbind", llply(res, amv_dim)))
- if (nrow(dims) != 1) stop("Results must have the same dimensions.")
+ if (nrow(dims) != 1)
+ stop("Results must have the same dimensions.")
res_dim <- amv_dim(res[[1]])
res_labels <- amv_dimnames(res[[1]])
@@ -85,7 +87,7 @@ list_to_array <- function(res, labels = NULL, .drop = FALSE) {
}
index <- cbind(
- labels[rep(seq_len(nrow(labels)), each = nrow(res_index)), , drop = FALSE],
+ labels[rep(seq_len(nrow(labels)), each = nrow(res_index)), ,drop = FALSE],
res_index[rep(seq_len(nrow(res_index)), nrow(labels)), , drop = FALSE]
)
Please sign in to comment.
Something went wrong with that request. Please try again.