Learn R Programming

rosetta (version 0.3.12)

means: 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 )

Value

The means or sums.

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.

Examples

Run this code
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');

Run the code above in your browser using DataLab