Learn R Programming

Hmisc (version 5.3-0)

xy.group: Mean x vs. function of y in groups of x

Description

Compute mean x vs. a function of y (e.g. median) by quantile groups of x or by x grouped to have a given minimum number of observations. Deletes NAs in x and y before doing computations.

Usage

xy.group(x, y, m=150, g, fun=mean, result="list")

Arguments

Value

if result="list", a list with components x and y suitable for plotting. if result="matrix", matrix with rows corresponding to x-groups and columns named n, x, and y.

See Also

cut2, cutGn, tapply

Examples

Run this code
  if (FALSE) {
plot(xy.group(x, y, g=10))	#Plot mean y by deciles of x
xy.group(x, y, m=100, result="matrix")	#Print table, 100 obs/group
  }

Run the code above in your browser using DataLab