meansAndSums: Compute means and sums

meansR Documentation

Compute means and sums

Description

These functions allow easily computing means and sums. Note that if you attach rosetta to the search path,

Usage

means(
  ...,
  data = NULL,
  requiredValidValues = 0,
  returnIfInvalid = NA,
  silent = FALSE
)

sums(
  ...,
  data = NULL,
  requiredValidValues = 0,
  returnIfInvalid = NA,
  silent = FALSE
)

Arguments

...

The dataframe or vectors for which to compute the means or sums. When passing a dataframe as unnamed argument (i.e. in the "dots", ...), the means or sums for all columns in the dataframe will be computed. If you want to select one or more columns, make sure to pass the dataframe as data.

data

If a dataframe is passed as data, the values passed in the "dots" (...) will be taken as column names or indices in that dataframe. This allows easy indexing.

requiredValidValues

The number (if larger than 1) or proportion (if between 0 and 1) of values that have to be valid (i.e. nonmissing) before the mean or sum is returned.

returnIfInvalid

Which value to return for rows not meeting the criterion specified in requiredValidValues.

silent

Whether to suppress messages.

Value

The means or sums.

Examples

rosetta::means(mtcars$mpg, mtcars$disp, mtcars$wt);
rosetta::means(data=mtcars, 'mpg', 'disp', 'wt');
rosetta::sums(mtcars$mpg, mtcars$disp, mtcars$wt);
rosetta::sums(data=mtcars, 'mpg', 'disp', 'wt');

rosetta documentation built on March 7, 2023, 7:40 p.m.