Learn R Programming

OpasnetUtils (version 1.1.0)

oapply: Apply for ovariables

Description

Use tapply on the output slot

Usage

oapply(X, INDEX = NULL, FUN = NULL, cols = NULL, ..., simplify = TRUE)

Arguments

INDEX
list of factors, like tapply
FUN
function to apply
cols
names of columns to be removed (reverse INDEX)
...
optional arguments to FUN
simplify
like tapply

Value

  • Returns an ovariable, with output slot tapplied and marginal adjusted accordingly.

Details

See also: http://en.opasnet.org/

Examples

Run this code
a <- new("ovariable", name = "a", output = data.frame(A = c("a", "a", "b", "b"), 
    B = c("1", "2", "1", "2"), aResult = 1:4), marginal = c(TRUE, TRUE, FALSE))
oapply(a, FUN = sum, cols = "A")
oapply(a, a@output[c("A")], sum)

Run the code above in your browser using DataLab