Provides a set of static (Shared in Visual Basic) methods for querying objects that implement System.Collections.Generic.IEnumerable`1.
linq
01 Syntax
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| left_join | 1 | A left join is a type of relational join operation that combines two datasets based on a common column or variable. |
| progress | 1 | apply for the pipeline progress report |
| fastIndexing | 1 | create data index for the given input data sequence |
| take | 1 | take the first n items from the given input sequence data |
| match | 1 | Value Matching match returns a vector of the positions of (first) matches of its first argument in its second. |
| skip | 1 | Bypasses a specified number of elements in a sequence and then returns the remaining elements. |
| unique | 1 | Returns distinct elements from a sequence by using a specified IEqualityComparer to compare values. |
| projectAs | 1 | A lapply/sapply liked mapping function |
| where | 1 | Which indices are TRUE? The which test filter, Give the TRUE indices of a logical object, allowing for array indices. |
| whichMax | 1 | Where is the Min() or Max() or first TRUE or FALSE ? Determines the location, i.e., index of the (first) minimum or maximum of a numeric (or logical) vector. |
| whichMin | 1 | Where is the Min() or Max() or first TRUE or FALSE ? Determines the location, i.e., index of the (first) minimum or maximum of a numeric (or logical) vector. |
| first | 1 | Returns the first element of a sequence. |
| last | 1 | get the last element in the sequence |
| groupBy | 1 | group vector/list by a given evaluator or group a dataframe rows by the cell values of a specific column. |
| produceKeyedSequence | 1 | get key value from the input data sequence and then populate the key with the original value elements. |
| sort | 1 | Sorting or Ordering Vectors Sort (or order) a vector or factor (partially) into ascending or descending order. |
| orderBy | 1 | Sorts the elements of a sequence in ascending order according to a key. |
| reverse | 1 | reverse a given sequence |
| any | 1 | Are Some Values True? Given a set of logical vectors, is at least one of the values true? |
| all | 1 | Are All Values True? Given a set of logical vectors, are all of the values true? |
| split | 1 | split content sequence with a given condition as element delimiter. |
| select | 1 | Keep or drop columns using their names and types Select (and optionally rename) variables in a data frame, using a concise mini-language that makes it easy to refer to variabl… |
| switch | 1 | text labeler |
03 Members
A left join is a type of relational join operation that combines two datasets based on a common column or variable. The result of a left join includes all the rows from the left dataset and any matching rows from the right dataset.
| Name | Type | Description |
|---|---|---|
left | dataframe | - |
right | dataframe | - |
by | Object | the field name that used for join two data table, if the field name that specific by this parameter is existsed in both left and right. this parameter option also could be an integer value 1-based. |
grep | Object | text grep expression for the index key string value, see |
apply for the pipeline progress report
value range of parameter x should be in numeric range [0,100] if the progress function is invoked in a parallel stack environment.
| Name | Type | Description |
|---|---|---|
x | Object | the pipeline object or a progress number if current function invoke is occurs in a parallel task. |
msgFunc | Object | a text message to display or function for show message |
env | Environment | - |
just used for display the progress
progress(20);
[SET_PROGRESS] 20% Pipeline progress report
x |> progress("display progress info") |> blablabla() ;
create data index for the given input data sequence
| Name | Type | Description |
|---|---|---|
x | Array | a data array as sequence |
mode | Object | the element mode of the data input seuqnce x |
env | Environment | - |
take the first n items from the given input sequence data
| Name | Type | Description |
|---|---|---|
sequence | Object | the input sequence data |
n | Object | the number of first n element |
env | Environment | - |
Object, Object, Int32, Int32)Value Matching
match returns a vector of the positions of (first) matches of its first argument in its second.
find the index of the elements in input sequence x in the source target sequence table
find the index of (where x in table)
https://stackoverflow.com/questions/7530765/get-the-index-of-the-values-of-one-vector-in-another
first = c("a", "c", "b");
second = c("c", "b", "a");
match(second, first);
# c b a <-second
[1] 2 3 1| Name | Type | Description |
|---|---|---|
x | Object | vector or NULL: the values to be matched. Long vectors are supported. |
table | Object | vector or NULL: the values to be matched against. Long vectors are not supported. (using as index object.) |
nomatch | Int32 | the value to be returned in the case when no match is found. Note that it is coerced to integer. |
incomparables | Int32 | a vector of values that cannot be matched. Any value in x matching a value in this vector is assigned the nomatch value. For historical reasons, FALSE is equivalent to NULL. |
A vector of the same length as x. An integer vector giving the position in table of the first match if there Is a match, otherwise nomatch. If x[i] Is found To equal table[j] Then the value returned In the i-th position Of the Return value Is j, For the smallest possible j. If no match Is found, the value Is nomatch.
Bypasses a specified number of elements in a sequence and then returns the remaining elements.
| Name | Type | Description |
|---|---|---|
sequence | Object | An System.Collections.Generic.IEnumerable`1 to return elements from. |
n | Int32 | The number of elements to skip before returning the remaining elements. |
An System.Collections.Generic.IEnumerable`1 that contains the elements that occur after the specified index in the input sequence.
Returns distinct elements from a sequence by using a specified IEqualityComparer to compare values.
| Name | Type | Description |
|---|---|---|
items | Object | The sequence to remove duplicate elements from. |
getKey | RFunction | An IEqualityComparer to compare values. |
envir | Environment | - |
An IEnumerable that contains distinct elements from the source sequence.
A lapply/sapply liked mapping function
| Name | Type | Description |
|---|---|---|
sequence | Object | - |
project | RFunction | - |
envir | Environment | - |
Which indices are TRUE?
The which test filter, Give the TRUE indices of a logical object, allowing for array indices.
Unlike most other base R functions this does not coerce to x to logical: only arguments with typeof logical are accepted and others give an error.
| Name | Type | Description |
|---|---|---|
env | Object | - |
x | Object | a logical vector or array. NAs are allowed and omitted (treated as if FALSE). |
first | Boolean | get the first index element where the assert is TRUE, this parameter works for test expression is nothing |
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].
x = [TRUE FALSE FALSE TRUE];
print(which(x));
[1] 1 4
just returns the first element index which is assert as TRUE
print(which(x, first = TRUE));
[1] 1
Where is the Min() or Max() or first TRUE or FALSE ?
Determines the location, i.e., index of the (first) minimum or maximum of a numeric (or logical) vector.
| Name | Type | Description |
|---|---|---|
x | Object | numeric (logical, integer or double) vector or an R object for which the internal coercion to double works whose min or max is searched for. |
eval | Object | - |
env | Environment | - |
Missing and NaN values are discarded.
an integer Or on 64-bit platforms, if length(x) = n>= 2^31 an integer valued double of length 1 Or 0 (iff x has no non-NAs), giving the index of the first minimum Or maximum respectively of x.
If this extremum Is unique (Or empty), the results are the same As (but more efficient than) which(x == min(x, na.rm = True)) Or which(x == max(x, na.rm = True)) respectively.
Logical x – First True Or False
For a logical vector x with both FALSE And TRUE values, which.min(x) And which.max(x) return the index of the first FALSE Or TRUE, respectively, as FALSE < TRUE. However, match(FALSE, x) Or match(TRUE, x) are typically preferred, as they do indicate mismatches.
Where is the Min() or Max() or first TRUE or FALSE ?
Determines the location, i.e., index of the (first) minimum or maximum of a numeric (or logical) vector.
| Name | Type | Description |
|---|---|---|
x | Object | numeric (logical, integer or double) vector or an R object for which the internal coercion to double works whose min or max is searched for. |
eval | Object | - |
env | Environment | - |
Missing and NaN values are discarded.
an integer Or on 64-bit platforms, if length(x) = n>= 2^31 an integer valued double of length 1 Or 0 (iff x has no non-NAs), giving the index of the first minimum Or maximum respectively of x.
If this extremum Is unique (Or empty), the results are the same As (but more efficient than) which(x == min(x, na.rm = True)) Or which(x == max(x, na.rm = True)) respectively.
Logical x – First True Or False
For a logical vector x with both FALSE And TRUE values, which.min(x) And which.max(x) return the index of the first FALSE Or TRUE, respectively, as FALSE < TRUE. However, match(FALSE, x) Or match(TRUE, x) are typically preferred, as they do indicate mismatches.
Returns the first element of a sequence.
| Name | Type | Description |
|---|---|---|
sequence | Object | The System.Collections.Generic.IEnumerable`1 to return the first element of. |
test | RFunction | An element test assert lambda function for find the first element which matched with this test condition |
envir | Environment | - |
The first element in the specified sequence. NULL value will be returned if there is no element could be found in the given seuqnece or under the given test condition.
get the last element in the sequence
| Name | Type | Description |
|---|---|---|
sequence | Object | a general data sequence |
test | RFunction | if this test function is nothing, then means get the last element in the sequence. else if the function is not nothing, then means get the last element that which meet this test condition in the sequence data input. |
envir | Environment | - |
group vector/list by a given evaluator or group a dataframe rows by the cell values of a specific column.
this function could also accept a numeric tolerance error as the getKey for do numeric bin grouping
| Name | Type | Description |
|---|---|---|
sequence | Object | - |
getKey | Object | - |
env | Boolean | - |
get key value from the input data sequence and then populate the key with the original value elements.
| Name | Type | Description |
|---|---|---|
keyBy | Func(Of Object, Object) | - |
sequence | Object | - |
env | Environment | - |
err | Message | - |
element names will be returns as object reference if the given sequence** is a list. **
Object, Boolean, Object, Boolean)Sorting or Ordering Vectors
Sort (or order) a vector or factor (partially) into ascending or descending order. For ordering along more than one variable, e.g., for sorting data frames, see order.
sort is a generic function for which methods can be written, and sort.int is the internal method which is compatible with S if only the first three arguments are used. The Default sort method makes use Of order For classed objects, which In turn makes use Of the generic Function xtfrm (And can be slow unless a xtfrm method has been defined Or Is.numeric(x) Is True). Complex values are sorted first by the real part, Then the imaginary part. The "auto" method selects "radix" for short (less than 2^31 elements) numeric vectors, integer vectors, logical vectors And factors; otherwise, "shell". Except for method "radix", the sort order for character vectors will depend on the collating sequence of the locale in use: see Comparison. The sort order For factors Is the order Of their levels (which Is particularly appropriate For ordered factors). If partial Is Not NULL, it Is taken to contain indices of elements of the result which are to be placed in their correct positions in the sorted array by partial sorting. For each of the result values in a specified position, any values smaller than that one are guaranteed to have a smaller index in the sorted array And any values which are greater are guaranteed to have a bigger index in the sorted array. (This Is included for efficiency, And many of the options are Not available for partial sorting. It Is only substantially more efficient if partial has a handful of elements, And a full sort Is done (a Quicksort if possible) if there are more than 10.) Names are discarded for partial sorting. Method "shell" uses Shellsort (an O(n^{4/3}) variant from Sedgewick (1986)). If x has names a stable modification Is used, so ties are Not reordered. (This only matters if names are present.) Method "quick" uses Singleton (1969)'s implementation of Hoare's Quicksort method and is only available when x is numeric (double or integer) and partial is NULL. (For other types of x Shellsort is used, silently.) It is normally somewhat faster than Shellsort (perhaps 50% faster on vectors of length a million and twice as fast at a billion) but has poor performance in the rare worst case. (Peto's modification using a pseudo-random midpoint is used to make the worst case rarer.) This is not a stable sort, and ties may be reordered. Method "radix" relies on simple hashing to scale time linearly with the input size, i.e., its asymptotic time complexity Is O(n). The specific variant And its implementation originated from the data.table package And are due to Matt Dowle And Arun Srinivasan. For small inputs (< 200), the implementation uses an insertion sort (O(n^2)) that operates in-place to avoid the allocation overhead of the radix sort. For integer vectors of range less than 100,000, it switches to a simpler And faster linear time counting sort. In all cases, the sort Is stable; the order of ties Is preserved. It Is the default method for integer vectors And factors. The "radix" method generally outperforms the other methods, especially for character vectors And small integers. Compared to quick sort, it Is slightly faster for vectors with large integer Or real values (but unlike quick sort, radix Is stable And supports all na.last options). The implementation Is orders of magnitude faster than shell sort for character vectors, in part thanks to clever use of the internal CHARSXP table. However, there are some caveats with the radix sort If x Is a character vector, all elements must share the same encoding. Only UTF-8 (including ASCII) And Latin-1 encodings are supported. Collation always follows the "C" locale. Long vectors(with more than 2^32 elements) And complex vectors are Not supported yet.
| Name | Type | Description |
|---|---|---|
x | Object | For sort an R object with a class Or a numeric, complex, character Or logical vector. For sort.int, a numeric, complex, character Or logical vector, Or a factor. for sort a dataframe object, then it will sort by the value order which is defined via the given columns. |
decreasing | Boolean | logical. Should the sort be increasing or decreasing? For the "radix" method, this can be a vector of length equal to the number of arguments in .... For the other methods, it must be length one. Not available for partial sorting. |
na_last | Object | for controlling the treatment of NAs. If TRUE, missing values in the data are put last; if FALSE, they are put first; if NA, they are removed. |
For sort, the result depends on the S3 method which is dispatched. If x does not have a class sort.int is used and it description applies. For classed objects which do not have a specific method the default method will be used and is equivalent to x[order(x, ...)]: this depends on the class having a suitable method for [ (and also that order will work, which requires a xtfrm method). For sort.int the value Is the sorted vector unless index.return Is true, when the result Is a list with components named x And ix containing the sorted numbers And the ordering index vector. In the latter case, if method == "quick" ties may be reversed in the ordering (unlike sort.list) as quicksort Is Not stable. For method == "radix", index.return Is supported for all na.last modes. The other methods only support index.return when na.last Is NA. The index vector refers To element numbers after removal Of NAs: see order If you want the original element numbers. All attributes are removed from the Return value (see Becker et al, 1988, p.146) except names, which are sorted. (If Partial Is specified even the names are removed.) Note that this means that the returned value has no Class, except For factors And ordered factors (which are treated specially And whose result Is transformed back To the original Class).
Sorts the elements of a sequence in ascending order according to a key.
| Name | Type | Description |
|---|---|---|
x | Object | A sequence of values to order. |
getKey | Object | A function to extract a key from an element. and this parameter value can also be the field name or column name to sort. |
envir | Boolean | - |
An System.Linq.IOrderedEnumerable`1 whose elements are sorted according to a key. The sort result could be situations:
- a vector which is sort by the element evaluated value
- a list which is sort by the specific element value
- a dataframe which is sort its rows by a specific column value
Object)reverse a given sequence
| Name | Type | Description |
|---|---|---|
sequence | Object | - |
Object, Boolean)Are Some Values True?
Given a set of logical vectors, is at least one of the values true?
| Name | Type | Description |
|---|---|---|
test | Object | zero or more logical vectors. Other objects of zero length are ignored, and the rest are coerced to logical ignoring any class. |
narm | Boolean | logical. If true NA values are removed before the result Is computed. |
The value is a logical vector of length one.
Let x denote the concatenation of all the logical vectors in ... (after coercion), after removing NAs if requested by na.rm = TRUE.
The value returned Is True If at least one Of the values In x Is True, And False If all Of the values In x are False (including If there are no values). Otherwise the value Is NA (which can only occur If na.rm = False And ... contains no True values And at least one NA value).
Object, Boolean)Are All Values True?
Given a set of logical vectors, are all of the values true?
| Name | Type | Description |
|---|---|---|
test | Object | zero or more logical vectors. Other objects of zero length are ignored, and the rest are coerced to logical ignoring any class. |
narm | Boolean | logical. If true NA values are removed before the result is computed. |
The value is a logical vector of length one.
Let x denote the concatenation of all the logical vectors in ... (after coercion), after removing NAs if requested by na.rm = TRUE.
The value returned Is True If all Of the values In x are True (including If there are no values), And False If at least one Of the values In x Is False. Otherwise the value Is NA (which can only occur If na.rm = False And ... contains no False values And at least one NA value).
split content sequence with a given condition as element delimiter.
the generated result is different between the vector/list:
- for vector data: split the value array directly
- for list data: split the list keys array and then break the input list data into multiple parts by keys
| Name | Type | Description |
|---|---|---|
x | Object | a given data sequence |
delimiter | Object | an element test function to determine that element is a delimiter object |
argv | list |
|
env | Environment | - |
Keep or drop columns using their names and types
Select (and optionally rename) variables in a data frame, using a concise mini-language that makes it easy to refer to variables based on their name (e.g. a:f selects all columns from a on the left to f on the right) or type (e.g. where(is.numeric) selects all numeric columns).
| Name | Type | Description |
|---|---|---|
_data | dataframe | A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). See Methods, below, for more details. |
selectors | Boolean | <tidy-select> One or more unquoted expressions separated by commas. Variable names can be used as if they were positions in the data frame, so expressions like x:y can be used to select a range of variables. syntax for the selectors:
|
strict | list | By default when this function running in strict mode, an error message will be returned if there is a missing data fields exists in the selector list |
env | Environment | - |
An object of the same type as .data. The output has the following properties:
- Rows are Not affected.
- Output columns are a subset Of input columns, potentially With a different order. Columns will be renamed If new_name = old_name form Is used.
- Data frame attributes are preserved.
- Groups are maintained; you can't select off grouping variables.
text labeler
| Name | Type | Description |
|---|---|---|
x | Object | - |
labels | list | - |
env | Environment | - |
let labels = switch(c(...), gene = c(...), prot = c(...), metabolite = c(...), NA = "kegg_pathway" );
print(labels);