Rcpp tapply Generator

Description

Use this function as a generator for your own tapply functions; that is, functions you would like to apply split over some grouping variable. Note that we restrict ourselves to the case where we return a scalar as output; rather than the more general output of tapply.

Usage

1
2
3
4
5
rcpp_tapply_generator(fun, includes = NULL, depends = NULL, inline = TRUE,
  returnType = "double", name = NULL, file = NULL, additional = NULL)

Rcpp_tapply_generator(fun, includes = NULL, depends = NULL, inline = TRUE,
  returnType = "double", name = NULL, file = NULL, additional = NULL)

Arguments

fun

A character string defining the C++ function. It must be in terms of a variable x.

includes

Other C++ libraries to include. For example, to include boost/math.hpp, you could pass c("<boost/math.hpp>"). Rcpp is included by default, unless RcppArmadillo is included as well (since Rcpp is included as part of the RcppArmadillo include)

depends

Other libraries to link to. Linking is done through Rcpp attributes.

returnType

The return type of your function; note that we require that the generator returns a scalar value of type double, int, or bool.

inline

boolean; mark this function as inline? This may or may not increase execution speed.

name

An internal name for the function.

file

A location to output the file. Defaults to a temporary file as generated by tempfile().

additional

Other C++ code you want to include; e.g. helper functions. This code will be inserted as-is above the code in fun.

Details

Note that we simplify differently than base R tapply: when simplify=TRUE, we call unlist on the output; hence, a named vector is returned.

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.