Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

group

Some summary statistics of a vector for each level of a grouping variable.


Description

Some summary statistics of a vector for each level of a grouping variable.

Usage

group(x,ina,method="sum",ina.min=NULL,ina.max = NULL,
	ina.length.unique=NULL,mad.method="median")
group.sum(x, ina,ina.max = NULL,ina.min = NULL)
group.mean(x, ina,ina.max = max(ina))

Arguments

x

A numerical vector with data.

ina

A numerical vector with numbers. Note that zero and negative values are not allowed as this can cause R to run forever or crash.

ina.length.unique

Length of the unique numerical values of ina argument.

method

A character vector with values "sum", "var", "all", "any", "mad", "mean", "med", "min", "max", "min.max".

ina.max

Maximum number for vector ina.

ina.min

Minimum number for vector ina.

mad.method

A character vector with values "median", for median absolute deviation or "mean", for mean absolute deviation. This works only with method="mad".

Details

This command works only for vectors. Median absolute deviation, mean, median, minimum, maximum are some of the options offered.

Value

A vector with the variance, or standard deviation, or mean, or minimum, or maximum, or median, or minimum-maximum of x for each distinct value of ina.

Author(s)

Manos Papadakis and Michail Tsagris

R implementation and documentation: Manos Papadakis <papadakm95@gmail.com> and Michail Tsagris <mtsagris@yahoo.gr>.

See Also

Examples

## Not run: 
x <- rgamma(100,1, 4)
ina <- sample(1:5, 100, TRUE)
res<-group(x, ina,method="var")


## End(Not run)

Rfast

A Collection of Efficient and Extremely Fast R Functions

v2.0.1
GPL (>= 2.0)
Authors
Manos Papadakis, Michail Tsagris, Marios Dimitriadis, Stefanos Fafalios, Ioannis Tsamardinos, Matteo Fasiolo, Giorgos Borboudakis, John Burkardt, Changliang Zou, Kleanthi Lakiotaki and Christina Chatzipantsiou.
Initial release
2020-09-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.