cset(sets)
cset()所属R语言包:sets
Customizable sets
可自定义的组
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Creation and manipulation of customizable sets.
创建和操作的可定制套。
用法----------Usage----------
cset(gset,
orderfun = sets_options("orderfun"),
matchfun = sets_options("matchfun"))
cset_support(x)
cset_core(x, na.rm = FALSE)
cset_peak(x, na.rm = FALSE)
cset_height(x, na.rm = FALSE)
cset_memberships(x, filter = NULL)
cset_universe(x)
cset_bound(x)
cset_transform_memberships(x, FUN, ...)
cset_concentrate(x)
cset_dilate(x)
cset_normalize(x, height = 1)
cset_defuzzify(x, method = c("meanofmax", "smallestofmax", "largestofmax", "centroid"))
matchfun(FUN)
cset_orderfun(x)
cset_matchfun(x)
cset_orderfun(x) <- value
cset_matchfun(x) <- value
as.cset(x)
is.cset(x)
cset_is_empty(x, na.rm = FALSE)
cset_is_subset(x, y, na.rm = FALSE)
cset_is_proper_subset(x, y, na.rm = FALSE)
cset_is_equal(x, y, na.rm = FALSE)
cset_contains_element(x, e)
cset_is_set(x, na.rm = FALSE)
cset_is_multiset(x, na.rm = FALSE)
cset_is_fuzzy_set(x, na.rm = FALSE)
cset_is_set_or_multiset(x, na.rm = FALSE)
cset_is_set_or_fuzzy_set(x, na.rm = FALSE)
cset_is_fuzzy_multiset(x)
cset_is_crisp(x, na.rm = FALSE)
cset_has_missings(x)
cset_cardinality(x, type = c("absolute", "relative"), na.rm = FALSE)
cset_union(...)
cset_mean(x, y, type = c("arithmetic", "geometric", "harmonic"))
cset_product(...)
cset_difference(...)
cset_intersection(...)
cset_symdiff(...)
cset_complement(x, y)
cset_power(x)
cset_cartesian(...)
cset_combn(x, m)
## S3 method for class 'cset'
cut(x, level = 1, type = c("alpha", "nu"), strict = FALSE, ...)
## S3 method for class 'cset'
mean(x, ..., na.rm = FALSE)
## S3 method for class 'cset'
median(x, na.rm = FALSE)
## S3 method for class 'cset'
length(x)
参数----------Arguments----------
参数:x
For as.cset() and is.cset(): an R object. A (c)set object otherwise.
对于as.cset()和is.cset():R对象。 (三)集对象,否则。
参数:y
A (c)set object.
(三)集对象。
参数:gset
A generalized set (or some other R object coercible to it).
广义集(或其他一些R对象强制转换的话)。
参数:matchfun
A function for matching similar elements, comparable to match, taking two arguments: x (vector of elements to be matched) and table (vector of elements to be matched against). The return value is an integer vector of the matching positions (or NA if there is no match). Note that the default behavior is to test for identity.
match,两个参数:一个功能相似的元素进行匹配,具有可比性x(矢量匹配的元素)和table(向量的元素进行匹配)。返回值是一个整数向量的匹配位置(或NA,如果有不匹配)。需要注意的是,默认行为是测试身份。
参数:FUN
A predicate testing for equality of two objects.
一个谓词测试两个对象平等的。
参数:orderfun
A function taking a list and returning an integer vector, specifying the order in which an iterator processes the set elements. Alternatively, the index vector can be specified directly.
甲函数的列表和返回一个整数向量,指定一个迭代器处理的集合元素的顺序进行。或者,可以直接指定索引向量。
参数:value
A new match function (order function).
一个新的匹配函数的(顺序功能)。
参数:type
For gset_cardinality(): cardinality type (either "absolute" or "relative"). For gset_mean(): mean type ("arithmetic", "geometric", or "harmonic"). For "cut": either "alpha" or "nu".
对于gset_cardinality():基数类型("absolute"或"relative")。对于gset_mean():平均型("arithmetic","geometric",或"harmonic")。对于"cut"是"alpha"或"nu"。
参数:strict
Logical indicating whether the cut level must be exceeded strictly (“greater than”) or not (“greater than or equal”).
逻辑指示的切割水平是否严格必须超过(“大于”)或没有(“大于或等于”)。
参数:height
Double from the unit interval for scaling memberships.
双击缩放成员资格的单位间隔。
参数:e
An object of class element.
对象的类element。
参数:filter
Optional vector of elements to be filtered.
可选的元素向量进行过滤。
参数:m
Number of elements to choose.
选择的元素的数量。
参数:method
Currently, only "Jaccard" is implemented.
目前,仅是"Jaccard"实施。
参数:level
The minimum membership level.
成员的最低水平。
参数:na.rm
logical indicating whether NA values should be removed.
逻辑是否NA值应该被删除。
参数:...
For cset_<VAR>foo</VAR>(): (c)set objects. For the mean and sort methods: additional parameters internally passed to mean and order, respectively. For gset_transform_memberships: further arguments passed to FUN. For cut: currently not used.
对于cset_<VAR>foo</VAR>():(C)集对象。内部的平均值和排序方法:额外的参数传递给mean和order,。对于gset_transform_memberships:进一步参数传递给FUN。对于cut:目前没有使用。
Details
详细信息----------Details----------
Customizable sets extend generalized sets in two ways: First, users can control the way elements are matched, i.e., define equivalence classes of elements. Second, an order function (or permutation index) can be specified for each set for changing the order in which iterators such as as.list process the elements. The latter in particular influences the labeling and print methods for customizable sets.
可自定义的集延长广义的套在两个方面:首先,用户可以控制元素相匹配的方式,即,确定等价类的元素。其次,为了功能(或置换指数),可以为每个组指定用于改变的顺序进行的迭代器,如as.list处理元素。特别是影响后者的标签和打印方法可定制的集。
The match function needs to be vectorized in a similar way than match. matchfun can be used to create such a function from a “simple” predicate testing for equality (such as, e.g., identical). Make sure, however, to create the same function only once.
以类似的方式比match匹配功能需要量化的。 matchfun可以用来创建这样的功能从“简单”的谓词平等的测试(如,例如,identical)。确保创建相同的功能只有一次。
Note that operations on customizable sets require the same match function for all sets involved. The order function can differ, but will then be stripped from the result.
需要注意的是定制的集上的操作要求所涉及的所有组相同的匹配功能。为了功能会有所不同,但结果将被剥离。
sets_options can be used to conveniently switch the default match and/or order function if a number of cset objects need to be created.
sets_options可以方便地切换缺省情况下,匹配和/或命令的功能,如果一些cset对象需要被创建。
参考文献----------References----------
Generalized and customizable sets in R, Journal of Statistical Software 31(2), 1–27. http://www.jstatsoft.org/v31/i02/
参见----------See Also----------
set for (“ordinary”) sets, gset for generalized sets, cset_outer, and tuple for tuples (“vectors”).
set(“普通”)设置,gset广义集,cset_outer和tuple的元组(“向量”)。
实例----------Examples----------
## default behavior of sets: matching of elements is very strict[#默认行为集:匹配的元素是非常严格的]
## Note that on most systems, 3.3 - 2.2 != 1.1[#请注意,在大多数系统中,3.3 - 2.2 = 1.1]
x <- set("1", 1L, 1, 3.3 - 2.2, 1.1)
print(x)
y <- set(1, 1.1, 2L, "2")
print(y)
1L %e% y
set_union(x, y)
set_intersection(x, y)
set_complement(x, y)
## Now use the more sloppy match()-function. [#现在使用的较稀松的比赛()函数。]
## Note that 1 == "1" == 1L ...[#注意:1 ==“1”== 1L ...]
X <- cset(x, matchfun = match)
print(X)
Y <- cset(y, matchfun = match)
print(Y)
1L %e% Y
cset_union(X, Y)
cset_intersection(X, Y)
cset_complement(X, Y)
## Same using all.equal().[#一样的的使用all.equal()。]
## This is a non-vectorized predicate, so use matchfun[#这是一个非向量化谓词,所以使用matchfun“]
## to generate a vectorized version:[#生成一个量化的版本:]
FUN <- matchfun(function(x, y) isTRUE(all.equal(x, y)))
X <- cset(x, matchfun = FUN)
print(X)
Y <- cset(y, matchfun = FUN)
print(Y)
1L %e% Y
cset_union(X, Y)
cset_intersection(X, Y)
cset_complement(X, Y)
### change default functions via set_option[##更改默认通过set_option功能的]
sets_options("matchfun", match)
cset(x)
cset(y)
cset(1:3) <= cset(c(1,2,3))
### restore package defaults[##恢复包默认]
sets_options("matchfun", NULL)
### customized order function[##客户订单功能]
FUN <- function(x) order(as.character(x), decreasing = TRUE)
Z <- cset(letters[1:5], orderfun = FUN)
print(Z)
as.character(Z)
## converter for ordered factors keeps order[#转炉为保持秩序有序因子]
o <- ordered(c("a", "b", "a"), levels = c("b", "a"))
as.set(o)
as.cset(o)
## converter for other data types keep order if the elements are unique:[#转炉维持秩序,如果其他数据类型的元素是唯一的:]
as.cset(c("A", "quick", "brown", "fox"))
as.cset(c("A", "quick", "brown", "fox", "quick"))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|