# xy.group

From Hmisc v4.3-0
by Frank E Harrell Jr

##### Mean x vs. function of y in groups of x

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

- Keywords
- nonparametric, category

##### Usage

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

##### Arguments

- x
a vector, may contain NAs

- y
a vector of same length as x, may contain NAs

- m
number of observations per group

- g
number of quantile groups

- fun
function of y such as median or mean (the default)

- result
"list" (the default), or "matrix"

##### 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

##### Examples

```
# NOT RUN {
# 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
# }
```

*Documentation reproduced from package Hmisc, version 4.3-0, License: GPL (>= 2)*

### Community examples

Looks like there are no examples yet.