isValley
Syntax
isValley(X, [strict=true])
Arguments
X is a numeric vector/matrix/table.
strict is a Boolean value. The default value is true.
-
If strict = true, the adjacent elements cannot be NULL and are strictly greater than the element;
-
If strict = false, the adjacent elements cannot be NULL and are no smaller than the element.
Details
If X is a vector, check if each element in X is the valley.
If X is a matrix, perform the aforementioned calculations on each column and return a matrix of the same size as X.
If X is a table, only the numeric columns are involved in the calculations.
Examples
v = [3.1, 2.2, 2.2, 2.2, 1.3, 2.1, 1.2]
isValley(v)
// output
[false,false,false,false,true,false,false]
v = [3.1, 2.2, 2.2, 2.2, 2.6, 1, 1.2]
isValley(v)
// output
[false,false,false,false,false,true,false]
isValley(v, false)
// output
[false,true,true,true,false,true,false]
// Perform the calculations on each column in a matrix
m = matrix(5.3 5.8 5.6 NULL 5.7 1.2, 4.5 3.5 4.6 2.8 3.9 NULL)
isValley(m)
#0 | #1 |
---|---|
false | false |
false | true |
false | false |
false | true |
false | false |
false | false |
// Perform the calculations on the numeric columns in a table
t = table(`01`01`00`01`02`00 as id, 2022.01.01 + 1..6 as date, 388.3 390.6 390.8 390.6 390.3 391.5 as price)
isValley(t)
id | date | price |
---|---|---|
01 | 2022.01.02 | false |
01 | 2022.01.03 | false |
00 | 2022.01.04 | false |
01 | 2022.01.05 | false |
02 | 2022.01.06 | true |
00 | 2022.01.07 | false |
Related function: isPeak