LOCS {bimets} | R Documentation |
Select Time Series Indices
Description
This function returns the indices 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.
Usage
LOCS(x=NULL, options='ALL', ...)
Arguments
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. |
Value
This function returns a numerical array built with the indices of the values that are TRUE
in the input boolean array or in the input boolean time series.
See Also
NOELS
is.bimets
BIMETS indexing
TSERIES
GETYEARPERIOD
NOELS
NAMELIST
INTS
TSINFO
TABIT
ELIMELS
Examples
#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)