~ubuntu-branches/ubuntu/precise/r-cran-slam/precise

« back to all changes in this revision

Viewing changes to man/rollup.Rd

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2011-02-10 11:41:40 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20110210114140-juiktz2cqqhznpyn
Tags: 0.1-20-1
* New upstream release

* debian/control: Set (Build-)Depends: to current R version

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
\usage{
15
15
rollup(x, MARGIN, INDEX, FUN, ...)
16
16
 
17
 
\method{rollup}{simple_triplet_matrix}(x, MARGIN, INDEX, FUN, \dots)
18
 
\method{rollup}{simple_sparse_array}(x, MARGIN, INDEX, FUN, \dots)
19
 
\method{rollup}{matrix}(x, MARGIN, INDEX, FUN, \dots)
20
 
\method{rollup}{array}(x, MARGIN, INDEX, FUN, \dots)
 
17
\method{rollup}{simple_triplet_matrix}(x, MARGIN, INDEX, FUN = sum, \dots)
 
18
\method{rollup}{simple_sparse_array}(x, MARGIN, INDEX, FUN = sum, \dots)
 
19
\method{rollup}{matrix}(x, MARGIN, INDEX, FUN = sum, \dots)
 
20
\method{rollup}{array}(x, MARGIN, INDEX, FUN = sum, \dots)
21
21
}
22
22
\arguments{
23
23
  \item{x}{a sparse array containing numeric, integer, or logical values.
24
24
}
25
 
  \item{MARGIN}{a vector giving the subscripts of the dimensions to be rolled up.
 
25
  \item{MARGIN}{a vector giving the subscripts (names) of the dimensions to be rolled up.
26
26
}
27
27
  \item{INDEX}{a corresponding (\code{list} of) \code{factor} (components) in the sense that \code{as.factor(f)} defines the grouping.}
28
 
  \item{FUN}{the function to be applied. Note that only functions that return a scalar value are applicable.
 
28
  \item{FUN}{the name of the function to be applied.
29
29
}
30
30
  \item{\dots}{optional arguments to \code{FUN}.
31
31
}
34
34
Provides fast summation over the rows or columns of sparse matrices in
35
35
\code{simple_triplet}-form.
36
36
 
37
 
The default method tries to coerce \code{x} to \code{array}.
 
37
Note that the default method tries to coerce \code{x} to \code{array}.
38
38
}
39
39
\value{
40
40
An object of the same class as \code{x} where for class
57
57
x <- matrix(c(1, 0, 0, 2, 1, NA), nrow = 2, 
58
58
            dimnames = list(A = 1:2, B = 1:3))
59
59
x
60
 
zz <- rollup(x, 2L, c(1,2,1), sum, na.rm = TRUE)
 
60
zz <- rollup(x, 2L, c(1,2,1), na.rm = TRUE)
61
61
zz
62
62
##
63
63
s <- as.simple_triplet_matrix(x)
64
 
z <- rollup(s, 2L, c(1,2,1), sum, na.rm = TRUE)
 
64
z <- rollup(s, 2L, c(1,2,1), na.rm = TRUE)
65
65
identical(zz, as.matrix(z))
66
66
##
67
67
a <- as.simple_sparse_array(s)
68
 
z <- rollup(a, 2L, c(1,2,1), sum, na.rm = TRUE)
 
68
z <- rollup(a, 2L, c(1,2,1), na.rm = TRUE)
69
69
identical(as.array(zz), as.array(z))
70
70
##
71
 
zz <- rollup(x, 2L, c(1,NA,1), sum, na.rm = TRUE)
 
71
zz <- rollup(x, 2L, c(1,NA,1), na.rm = TRUE)
72
72
zz
73
73
##
74
 
z  <- rollup(s, 2L, c(1,NA,1), sum, na.rm = TRUE)
 
74
z  <- rollup(s, 2L, c(1,NA,1), na.rm = TRUE)
75
75
identical(zz, as.matrix(z))
76
76
##
77
 
z  <- rollup(a, 2L, c(1,NA,1), sum, na.rm = TRUE)
 
77
z  <- rollup(a, 2L, c(1,NA,1), na.rm = TRUE)
78
78
identical(as.array(zz), as.array(z))
79
79
}
80
80
\keyword{array}