Set Operations
set
01 Syntax
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| unset | 1 | unset — Unset the feature slots value from a given variable |
| table | 1 | Cross Tabulation and Table Creation table uses the cross-classifying factors to build a contingency table of the counts at each combination of factor levels. |
| setdiff | 1 | setdiff: Set Difference of Subsets |
| rev | 1 | Reverse Elements rev provides a reversed version of its argument. |
| count | 1 | is a table liked function for count string occurance number |
| intersect | 1 | Performs set intersection |
| union | 1 | Performs set union |
| indexOf | 1 | Create the hash index for element search |
| match_val_against | 1 | create subset of the given listSet via tuple value match against with the given index_set. |
| duplicated | 1 | Determine Duplicate Elements duplicated() determines which elements of a vector or data frame are duplicates of elements with smaller subscripts, and returns a logical vecto… |
| crossing | 1 | Find Unique Combinations of All Elements from Two Vectors in R. |
| combn | 1 | Generate All Combinations of n Elements, Taken m at a Time Generate all combinations of the elements of x taken m at a time. |
| jaccard | 1 | The Jaccard Index, also known as the Jaccard similarity coefficient, is a statistic used in understanding the similarities between sample sets. |
| createSet | 1 | create a collection set based on a given vector or tuple list |
| set_ratio | 1 | equivalent to: length(a) / length(b) |
03 Members
unset — Unset the feature slots value from a given variable
the orginal object will be modified by this function
| Name | Type | Description |
|---|---|---|
x | Object | should be a tuple list object or dataframe object |
args | list | the features names to deletes from the given object x. |
env | Environment | - |
String(), Nullable(Of Boolean))Cross Tabulation and Table Creation
table uses the cross-classifying factors to build a contingency table of the counts at each combination of factor levels.
| Name | Type | Description |
|---|---|---|
x | String() | - |
setdiff: Set Difference of Subsets
Reverse Elements
rev provides a reversed version of its argument. It is generic function with a default method for vectors and one for dendrograms.
Note that this Is no longer needed (nor efficient) For obtaining vectors sorted into descending order, since that Is now rather more directly achievable by sort(x, decreasing = True).
| Name | Type | Description |
|---|---|---|
x | Object | a vector Or another Object For which reversal Is defined. |
env | list | - |
Array)is a table liked function for count string occurance number
| Name | Type | Description |
|---|---|---|
str | Array | A character vector that may contains the duplicated string value |
Performs set intersection
| Name | Type | Description |
|---|---|---|
x | Object | vectors (of the same mode) containing a sequence of items (conceptually) with no duplicated values. |
y | Object | vectors (of the same mode) containing a sequence of items (conceptually) with no duplicated values. |
Performs set union
| Name | Type | Description |
|---|---|---|
x | Object | vectors (of the same mode) containing a sequence of items (conceptually) with no duplicated values. |
y | Object | vectors (of the same mode) containing a sequence of items (conceptually) with no duplicated values. |
Create the hash index for element search
| Name | Type | Description |
|---|---|---|
x | Object | - |
getKey | Object | extract a character vector from one of the elements inside the collection x, using as the index key. |
env | Environment | - |
create subset of the given listSet via tuple value match against with the given index_set.
| Name | Type | Description |
|---|---|---|
listSet | list | - |
index_set | Object | - |
Object, Environment)Determine Duplicate Elements
duplicated() determines which elements of a vector or data frame are duplicates of elements with smaller subscripts, and returns a logical vector indicating which elements (rows) are duplicates.
These are generic functions with methods for vectors (including lists), data frames and arrays (including matrices).
For the default methods, And whenever there are equivalent method definitions for duplicated And anyDuplicated, anyDuplicated(x, ...) Is a “generalized” shortcut for any(duplicated(x, ...)), in the sense that it returns the index i of the first duplicated entry x[i] if there Is one, And 0 otherwise. Their behaviours may be different when at least one of duplicated And anyDuplicated has a relevant method.
duplicated(x, fromLast = TRUE) Is equivalent to but faster than rev(duplicated(rev(x))).
The data frame method works by pasting together a character representation Of the rows separated by \r, so may be imperfect If the data frame has characters With embedded carriage returns Or columns which Do Not reliably map To characters.
The array method calculates For Each element Of the Sub-array specified by MARGIN If the remaining dimensions are identical To those For an earlier (Or later, When fromLast = True) element (In row-major order). This would most commonly be used To find duplicated rows (the Default) Or columns (With MARGIN = 2). Note that MARGIN = 0 returns an array Of the same dimensionality attributes As x.
Missing values("NA") are regarded As equal, numeric And complex ones differing from NaN; character strings will be compared In a “common encoding”; For details, see match (And unique) which use the same concept.
Values in incomparables will never be marked as duplicated. This Is intended to be used for a fairly small set of values And will Not be efficient for a very large set.
When used on a data frame with more than one column, Or an array Or matrix when comparing dimensions of length greater than one, this tests for identity of character representations. This will catch people who unwisely rely on exact equality of floating-point numbers!
Except for factors, logical And raw vectors the default nmax = NA Is equivalent to nmax = length(x). Since a hash table of size 8*nmax bytes Is allocated, setting nmax suitably can save large amounts of memory. For factors it Is automatically set to the smaller of length(x) And the number of levels plus one (for NA). If nmax Is set too small there Is liable to be an error nmax = 1 Is silently ignored.
Long vectors are supported For the Default method Of duplicated, but may only be usable if nmax Is supplied.
| Name | Type | Description |
|---|---|---|
x | Object | a vector Or a data frame Or an array Or NULL. |
duplicated(): For a vector input, a logical vector of the same length as x. For a data frame, a logical vector with one element for each row. For a matrix or array, and when MARGIN = 0, a logical array with the same dimensions and dimnames.
Find Unique Combinations of All Elements from Two Vectors in R. Expand data frame to include all possible combinations of values.
| Name | Type | Description |
|---|---|---|
a | Array | - |
b | Array | - |
Generate All Combinations of n Elements, Taken m at a Time
Generate all combinations of the elements of x taken m at a time. If x is a positive integer, returns all combinations of the elements of seq(x) taken m at a time. If argument FUN is not NULL, applies a function given by the argument to each point. If simplify is FALSE, returns a list; otherwise returns an array, typically a matrix. ... are passed unchanged to the FUN function, if specified.
Factors x are accepted.
| Name | Type | Description |
|---|---|---|
x | Object | vector source For combinations, Or Integer n For x <- seq_len(n). |
m | Int32 | number of elements to choose. |
A list or array, see the simplify argument above. In the latter case, the identity dim(combn(n, m)) == c(m, choose(n, m)) holds.
The Jaccard Index, also known as the Jaccard similarity coefficient, is a statistic used in understanding the similarities between sample sets. The measurement emphasizes similarity between finite sample sets, and is formally defined as the size of the intersection divided by the size of the union of the sample sets.
| Name | Type | Description |
|---|---|---|
x | Array | - |
y | Array | - |
env | Environment | - |
create a collection set based on a given vector or tuple list
| Name | Type | Description |
|---|---|---|
x | Object | - |
mode | Object | - |
env | Environment | - |
equivalent to: length(a) / length(b)