which(base)
which()所属R语言包:base
Which indices are TRUE?
这指数是真的吗?
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Give the TRUE indices of a logical object, allowing for array indices.
给TRUE一个逻辑对象指标,允许数组的索引。
用法----------Usage----------
which(x, arr.ind = FALSE, useNames = TRUE)
arrayInd(ind, .dim, .dimnames = NULL, useNames = FALSE)
参数----------Arguments----------
参数:x
a logical vector or array. NAs are allowed and omitted (treated as if FALSE).
logical向量或数组。 NAS是允许的,省略(如果FALSE处理)。
参数:arr.ind
logical; should array indices be returned when x is an array?
逻辑数组索引时返回x是一个数组?
参数:ind
integer-valued index vector, as resulting from which(x).
整型值的索引向量,从which(x)。
参数:.dim
dim(.) integer vector
dim(.)整数向量
参数:.dimnames
optional list of character dimnames(.), of which only .dimnames[[1]] is used.
可选列表的字符dimnames(.),其中.dimnames[[1]]使用。
参数:useNames
logical indicating if the value of arrayInd() should have (non-null) dimnames at all.
逻辑表明,如果应该有arrayInd()(非null)dimnames在所有的价值。
值----------Value----------
If arr.ind == FALSE (the default), an integer vector with length equal to sum(x), i.e., to the number of TRUEs in x; Basically, the result is (1:length(x))[x].
如果arr.ind == FALSE(默认),length平等sum(x),即TRUEx的的整数向量;基本上,结果(1:length(x))[x]。
If arr.ind == TRUE and x is an array (has a dim attribute), the result is arrayInd(which(x), dim(x), dimnames(x)), namely a matrix whose rows each are the indices of one element of x; see Examples below.
如果arr.ind == TRUE和x是array(dim属性),其结果是arrayInd(which(x), dim(x), dimnames(x)),即矩阵的每一行是一个指数元素x;见下面的例子。
作者(S)----------Author(s)----------
Werner Stahel and Peter Holzer (ETH Zurich) proposed the
<code>arr.ind</code> option.
参见----------See Also----------
Logic, which.min for the index of the minimum or maximum, and match for the first index of an element in a vector, i.e., for a scalar a, match(a,x)
Logic,which.min最小或最大的索引,match在一个向量的元素,即第一个索引,一个标a,match(a,x)
举例----------Examples----------
which(LETTERS == "R")
which(ll <- c(TRUE,FALSE,TRUE,NA,FALSE,FALSE,TRUE))#> 1 3 7[> 1 3 7]
names(ll) <- letters[seq(ll)]
which(ll)
which((1:12)%%2 == 0) # which are even?[这是什?]
which(1:10 > 3, arr.ind=TRUE)
( m <- matrix(1:12,3,4) )
which(m %% 3 == 0)
which(m %% 3 == 0, arr.ind=TRUE)
rownames(m) <- paste("Case",1:3, sep="_")
which(m %% 5 == 0, arr.ind=TRUE)
dim(m) <- c(2,2,3); m
which(m %% 3 == 0, arr.ind=FALSE)
which(m %% 3 == 0, arr.ind=TRUE)
vm <- c(m)
dim(vm) <- length(vm) #-- funny thing with length(dim(...)) == 1[ - 有趣的事情长度(暗淡(...))== 1]
which(vm %% 3 == 0, arr.ind=TRUE)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|