rollup(slam)
rollup()所属R语言包:slam
Rollup Sparse Arrays
汇总稀疏数组
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Rollup (aggregate) sparse arrays along arbitrary dimensions.
汇总(总)沿任意尺寸的稀疏数组。
用法----------Usage----------
rollup(x, MARGIN, INDEX, FUN, ...)
## S3 method for class 'simple_triplet_matrix'
rollup(x, MARGIN, INDEX = NULL, FUN = sum, ...)
## S3 method for class 'simple_sparse_array'
rollup(x, MARGIN, INDEX = NULL, FUN = sum, ...,
DROP = FALSE, EXPAND = c("none", "sparse", "dense", "all"))
## S3 method for class 'matrix'
rollup(x, MARGIN, INDEX = NULL, FUN = sum, ..., DROP = FALSE)
## S3 method for class 'array'
rollup(x, MARGIN, INDEX = NULL, FUN = sum, ..., DROP = FALSE)
参数----------Arguments----------
参数:x
a sparse (or dense) array, typically of numeric or logical values.
一个稀疏(密)阵列,通常是数字或逻辑值。
参数:MARGIN
a vector giving the subscripts (names) of the dimensions to be rolled up.
的向量提供的下标(名字)的尺寸被卷起。
参数:INDEX
a corresponding (list of) factor (components) in the sense that as.factor defines the grouping(s). If NULL collapses the corresponding dimension(s) (default).
一个相应的(list)factor(组件),在这个意义上,as.factor定义的分组()。如果NULL倍数相应的尺寸(S)(默认)。
参数:FUN
the name of the function to be applied.
要施加的功能的名称。
参数:DROP
option to delete the dimensions of the result which have only one level.
选项以删除结果具有只有一个级别的尺寸。
参数:EXPAND
the cell expansion method to use (see Details).
电池膨胀的使用方法(见详情)。
参数:...
optional arguments to FUN.
可选参数到FUN。
Details
详细信息----------Details----------
Provides fast summation over the rows or columns of sparse matrices in simple_triplet-form.
提供快速simple_triplet形式的稀疏矩阵的行或列的求和。
If (a component of) INDEX contains NA values the corresponding parts of x are omitted.
如果(一个组成部分)INDEX包含NA的值的相应部分的x被省略的。
For simple_sparse_array the following cell expansion methods are provided:
对于simple_sparse_array下面的单元格扩展的方法:
none: The non-zero entries of a cell, if any, are
none:的非零项的一个单元,如果没有,是
sparse: The number of zero entries of a cell is
sparse:的零的一个单元格的条目的数目是
dense: Cells with non-zero entries are expanded to
dense:与非零项的单元扩大到
all: All cells are expanded to a dense array
all:所有的单元都扩大了一片茂密的array
Note that the memory and time consumption increases with the level of expansion.
请注意,存储器和时间消耗增加的水平扩张。
Note that the default method tries to coerce x to array.
请注意,默认的方法试图强制x到array。
值----------Value----------
An object of the same class as x where for class simple_triplet_matrix the values are always of type double if FUN = sum (default).
对象具有相同类的x类simple_triplet_matrix类型的值总是double如果FUN = sum(默认)。
The dimnames corresponding to MARGIN are based on (the components of) INDEX.
dimnames相应的MARGIN(组件)INDEX的基础上。
注意----------Note----------
Currently most of the code is written in R and, therefore, the memory and time it consumes is not optimal.
目前,大多数的代码是在R写入,因此,它消耗的内存和时间不是最优的。
(作者)----------Author(s)----------
Christian Buchta
参见----------See Also----------
simple_triplet_matrix and simple_sparse_array for sparse arrays.
simple_triplet_matrix和simple_sparse_array稀疏数组。
apply for dense arrays.
apply密集阵列。
实例----------Examples----------
##[#]
x <- matrix(c(1, 0, 0, 2, 1, NA), nrow = 2,
dimnames = list(A = 1:2, B = 1:3))
x
apply(x, 1L, sum, na.rm = TRUE)
##[#]
rollup(x, 2L, na.rm = TRUE)
##[#]
rollup(x, 2L, c(1,2,1), na.rm = TRUE)
## omit[#省略]
rollup(x, 2L, c(1,NA,1), na.rm = TRUE)
## expand[#扩大]
a <- as.simple_sparse_array(x)
a
r <- rollup(a, 1L, FUN = mean, na.rm = TRUE, EXPAND = "dense")
as.array(r)
## [#]
r <- rollup(a, 1L, FUN = function(x, nz)
length(x) / (length(x) + nz),
EXPAND = "sparse"
)
as.array(r)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|