Apply a function that returns 64-bit integers over a list or vector
Source:R/helper_functions.R
sapply64.Rd
Wrappers for members of the lapply()
family intended for use when a
function FUN
returns a vector of integer64
objects.
vapply()
, sapply()
or replicate()
drop the integer64
class,
resulting in a vector of numerics that require conversion back to
64-bit integers. These functions restore the missing class
attribute.
Usage
sapply64(X, FUN, ..., simplify = TRUE, USE.NAMES = TRUE)
vapply64(X, FUN, FUN.LEN = 1, ...)
replicate64(n, expr, simplify = "array")
Arguments
- X
a vector (atomic or list) or an
expression
object. Other objects (including classed objects) will be coerced bybase::as.list
.- FUN
the function to be applied to each element of
X
: see ‘Details’. In the case of functions like+
,%*%
, the function name must be backquoted or quoted.- ...
optional arguments to
FUN
.- simplify
logical or character string; should the result be simplified to a vector, matrix or higher dimensional array if possible? For
sapply
it must be named and not abbreviated. The default value,TRUE
, returns a vector or matrix if appropriate, whereas ifsimplify = "array"
the result may be anarray
of “rank” (\(=\)length(dim(.))
) one higher than the result ofFUN(X[[i]])
.- USE.NAMES
logical; if
TRUE
and ifX
is character, useX
asnames
for the result unless it had names already. Since this argument follows...
its name cannot be abbreviated.- FUN.LEN
Integer specifying the length of the output of
FUN
.- n
integer: the number of replications.
- expr
the expression (a language object, usually a call) to evaluate repeatedly.
Details
For details of the underlying functions, see base::lapply()
.
Examples
sapply64(as.phylo(1:6, 6), as.TreeNumber)
#> integer64
#> [1] 1 2 3 4 5 6
vapply64(as.phylo(1:6, 6), as.TreeNumber, 1)
#> integer64
#> [1] 1 2 3 4 5 6
set.seed(0)
replicate64(6, as.TreeNumber(RandomTree(6)))
#> integer64
#> [1] 91 45 102 24 92 48