File: xy.group.Rd

package info (click to toggle)
hmisc 4.2-0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 3,332 kB
  • sloc: asm: 27,116; fortran: 606; ansic: 411; xml: 160; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,159 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
\name{xy.group}
\alias{xy.group}
\title{
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 average 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{
\item{x}{
a vector, may contain NAs
}
\item{y}{
a vector of same length as x, may contain NAs
}
\item{m}{
number of observations per group
}
\item{g}{
number of quantile groups
}
\item{fun}{
function of y such as median or mean (the default)
}
\item{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.
}
\seealso{
\code{\link{cut2}}, \code{\link{tapply}}
}
\examples{
# 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
}
\keyword{category}
\keyword{nonparametric}
\concept{grouping}
\concept{stratification}
\concept{aggregation}
\concept{discretization}