The R Project SVN R

Rev

Rev 61160 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 61160 Rev 61168
Line 19... Line 19...
19
  Subsets of \code{x[]} are averaged, where each subset consist of those
19
  Subsets of \code{x[]} are averaged, where each subset consist of those
20
  observations with the same factor levels.
20
  observations with the same factor levels.
21
}
21
}
22
\value{
22
\value{
23
  A numeric vector, say \code{y} of length \code{length(x)}.
23
  A numeric vector, say \code{y} of length \code{length(x)}.
24
  If \code{\dots} is \code{g1,g2}, e.g.,
24
  If \code{\dots} is \code{g1, g2}, e.g.,
25
  \code{y[i]} is equal to \code{FUN(x[j]}, for all \code{j} with
25
  \code{y[i]} is equal to \code{FUN(x[j]}, for all \code{j} with
26
  \code{g1[j] == g1[i]} and \code{g2[j] == g2[i])}.
26
  \code{g1[j] == g1[i]} and \code{g2[j] == g2[i])}.
27
}
27
}
28
\seealso{\code{\link{mean}}, \code{\link{median}}.}
28
\seealso{\code{\link{mean}}, \code{\link{median}}.}
29
\examples{
29
\examples{
30
require(graphics)
30
require(graphics)
31
 
31
 
32
ave(1:3)# no grouping -> grand mean
32
ave(1:3)  # no grouping -> grand mean
33
 
33
 
34
attach(warpbreaks)
34
attach(warpbreaks)
35
ave(breaks, wool)
35
ave(breaks, wool)
36
ave(breaks, tension)
36
ave(breaks, tension)
37
ave(breaks, tension, FUN = function(x) mean(x, trim = 0.1))
37
ave(breaks, tension, FUN = function(x) mean(x, trim = 0.1))
38
plot(breaks, main =
38
plot(breaks, main =
39
     "ave( Warpbreaks )  for   wool  x  tension  combinations")
39
     "ave( Warpbreaks )  for   wool  x  tension  combinations")
40
lines(ave(breaks, wool, tension              ), type = 's', col = "blue")
40
lines(ave(breaks, wool, tension              ), type = "s", col = "blue")
41
lines(ave(breaks, wool, tension, FUN = median), type = 's', col = "green")
41
lines(ave(breaks, wool, tension, FUN = median), type = "s", col = "green")
42
legend(40, 70, c("mean", "median"), lty = 1,
42
legend(40, 70, c("mean", "median"), lty = 1,
43
      col = c("blue","green"), bg = "gray90")
43
      col = c("blue","green"), bg = "gray90")
44
detach()
44
detach()
45
}
45
}
46
\keyword{univar}
46
\keyword{univar}