docomp: Do computations over some factors

View source: R/docomp.R

docompR Documentation

Do computations over some factors

Description

Do computations for several variables for some specific factors.

Usage

docomp(do, vars, factors, keep = NULL, dfr, method = c("fast", "slow"))

Arguments

do

The computation to perform. Implemented options are count, mode, and standard functions like mean, median, min, max, sd, var, sum, etc.

vars

The names of the columns for the variables.

factors

The names of the columns for the factors.

keep

The names of additional columns to keep.

dfr

The name of the data frame.

method

Use fast or slow method.

Details

This function do a specific computation for all the vars for each level's combination of the factors. Additional columns can be kept if specified in keep. All factors and keep values are converted to character. do = "count" counts the number of valid cases (excluding missing values).

Value

It returns a data frame with the computations.

Author(s)

Raul Eyzaguirre.

Examples

# Compute means across replications and then across locations for each genotype
vars <- c("rytha", "bc", "dm", "star", "nocr")
factors <- c("geno", "loc")
output1 <- docomp("mean", vars, factors, dfr = spg)
docomp("mean", vars, "geno", dfr = output1) 
# Compute maxima across replications for each genotype and location.
docomp("max", vars, factors, dfr = spg)

reyzaguirre/st4gi documentation built on Oct. 18, 2024, 3:04 p.m.