Description Usage Arguments Details Value Author(s) See Also Examples
Apply a function to each block in a blockformat
data set
and return the result in a suitable format.
1 2  blk.applyNto1(x, id, apply.fun, ind = NULL, fill = NA, ...)
blk.applyNtoN(x, id, apply.fun, ind = NULL, fill = NA, ...)

x 
A vector in 
id 
A valid 
apply.fun 
A function to apply to each block of 
ind 
A vector of logicals used to filter the values of 
fill 
A value to use when no other value is appropriate. See details. 
... 
Further arguments passed to 
These functions operate on data sets in blockformat
.
The function apply.fun
on each block of x
, similar to
tapply
. The values of x
passed to the function
can be filtered by using ind
to specify a subset.
If the objective is to extract specific values from x
rather
than to use a function to transform the values, then
blk.singleValue
or blk.repeatValue
should be used instead.
For blk.applyNto1
, the function apply.fun
should take
a vector as its first argument and return a vector of length 1. If
the returned vector has length greater than 1, then only the first
element will be kept and a warning issued. If the returned vector
has length 0, then the result for the correponding block is
NA
, and a warning is issued.
For blk.applyNtoN
, the function apply.fun
should take
a vector as its first argument and return a vector. The length of
the returned vector will be extended or reduced as necessary to
obtain a vector matching the length of the function input with
elements recycled if necessary. If the length of the input vector
is not a multiple of the length of the returned vector then a
warning is issued. In general, only functions for which the length
of the returned vector equals to the length of the input or 1
make sense.
The result contains the value fill
for blocks of size zero
(see blockformat
) or for which all ind
equals
FALSE
.
blk.applyNto1
returns a vector containing one value for
each level of id
.
blk.applyNtoN
returns a vector in
blockformat
with respect to id
.
Ben Rich <benjamin.rich@certara.com>
blockformat
blk.singleValue
, blk.repeatValue
tapply
, by
, aggregate
1 2 3 4 5 6 7 8 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.