Description Usage Arguments Details Value
Apply a function raggedly to a vector containing NAs.
1 | napply(x, FUN)
|
x |
a vector |
FUN |
a function |
Each consecutive stretch of non-NA values is treated as a separate input to the function (using ave
).
Can be used as a generalised method for functions that don't have a na.omit
option or when
it's important to maintain data structure and order.
The function is best used for FUN
s which return an output of the same size as the input.
If FUN
returns an atomic value for an input vector (eg mean
) the output is replicated across
all entries of x as necessary.
A vector of the same size and NA distribution as x
but containing FUN
-transformed data.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.