Select Time Series Indexes
This function returns the indexes of the input TRUE elements. The input can be either an array or a time series. The result is usually used as a structured index to produce a new array.
LOCS(x=NULL, options='ALL', ...)
x |
This function accepts as input a boolean array or a boolean time series, often as the result of a logic comparison between an expression and a numerical array or a numerical time series: |
options |
A selection option can refine the result: |
... |
Backward compatibility. |
This function returns a numerical array built with the indexes of the values that are TRUE in the input boolean array or in the input boolean time series.
#create ts
n=10
ts1=TSERIES((1:n),START=c(2000,1),FREQ=1)
print(LOCS(ts1>7,options='FIRST')) #print 8
#generate error: print LOCS(): input has more than one TRUE element.
tryCatch({print(LOCS(ts1>=3,options='UNIQUE'));},error=function(e){print(e$message);})
print(LOCS(is.na(c(1,2,NA,4,5,6,7,NA,NA)))) #print c(3,8,9)Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.