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
[0,0,0,0,1,0,0]
v = [3.1, 2.2, 2.2, 2.2, 2.6, 1, 1.2]
isValley(v)
// output
[0,0,0,0,0,1,0]
isValley(v, false)
// output
[0,1,1,1,0,1,0]
// 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 |
---|---|
0 | 0 |
0 | 1 |
0 | 0 |
0 | 1 |
0 | 0 |
0 | 0 |
// 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 | 0 |
01 | 2022.01.03 | 0 |
00 | 2022.01.04 | 0 |
01 | 2022.01.05 | 0 |
02 | 2022.01.06 | 1 |
00 | 2022.01.07 | 0 |
Related function: isPeak