-1

My question is a continuation of this:

Split a vector into chunks

What would be the best possible way to access of all these chunks. For example, is there an easy way to access these mini-vectors if I have around a hundred of them. I would be needing to find the minimum of each of these chunks and store the results in a new vector.

Subha Yoganandan
  • 325
  • 1
  • 6
  • 13

1 Answers1

0

Look at the plyr package there is family of function to process lists or vectors. In the post you mentioned, you see lists. Thus, use llply to have input as a list and output as a list, for vectors aaply is your choice.

# Examples from ?lapply
x <- list(a = 1:10, beta = exp(-3:3), logic = c(TRUE,FALSE,FALSE,TRUE))

> x
$a
 [1]  1  2  3  4  5  6  7  8  9 10

$beta
[1]  0.04978707  0.13533528  0.36787944  1.00000000  2.71828183  7.38905610 20.08553692

$logic
[1]  TRUE FALSE FALSE  TRUE

llply(x, mean)
llply(x, quantile, probs = 1:3/4)
Cron Merdek
  • 1,084
  • 1
  • 14
  • 25