colGroup: Column-wise summary statistics with grouping variables

View source: R/colGroup.R

Column-wise summary statistics with grouping variables R Documentation

Column-wise summary statistics with grouping variables

Description

Column-wise summary statistics with grouping variables.

Usage

colGroup(x,ina,method="sum",names=TRUE, std = FALSE)

Arguments

x

A matrix with data.

ina

A numerical vector specifying the groups. If you have numerical values, do not put zeros, but 1, 2, 3 and so on. The numbers must be consecutive, like 1,2,3,.. Do not put 1, 3, 4 as this will cause C++ to crash.

method

One of the: "sum", "min", "max", "median", "var".

names

Set the name of the result vector with the unique numbers of group variable.

std

A boolean variable specyfying whether you want the variances (FALSE) or the standard deviations (TRUE) of each column. This is taken into account only when method = "var".

Value

Column wise of grouping variables. You can also include diagonal to the check.

Author(s)

Manos Papadakis.

R implementation and documentation: Manos Papadakis papadakm95@gmail.com.

See Also

Quantile, colQuantile, rowQuantile

Examples


x <- matrix(runif(100 * 5), 100, 5)
id <- sample(1:3, 100, TRUE)

all.equal( colGroup(x, id), rowsum(x, id) )


Rfast2 documentation built on Aug. 8, 2023, 1:11 a.m.