find_repval: Find Repeated Values

Description Usage Arguments Value Examples

View source: R/data-clean.R

Description

Finds repeated values in the data and returns the respective column index.

Usage

1
find_repval(data, maxrep = 5)

Arguments

data

an nxp numerical data matrix.

maxrep

an integer, indicating the maximal number of repetitions allowed. Default is 5 (one business week).

Value

an index vector of the columns with more than maxrep repetitions in the time series.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(sp500)
sp500[,1] <- as.Date(sp500[,1],format="%d.%m.%Y",stringsAsFactors=FALSE)
sp500 <- sp500[,-which(substr(colnames(sp500),1,7)=="X.ERROR")]
NYSE_hol <- as.Date(timeDate::holidayNYSE(as.numeric(unique(format(sp500[,1],format="%Y")))))
no_trades <- sort(c(NYSE_hol, as.Date(c("2001-09-11","2001-09-12",
"2001-09-13","2001-09-14"), format="%Y-%m-%d")))
sp500 <- sp500[-match(no_trades,sp500[,1]),]
nonas <- which(apply(is.na(sp500[,-1]),2,sum)==0)
sp500 <- sp500[,c(1, nonas+1)]
repindex <- find_repval(sp500[,-1])

antshi/auxPort documentation built on Oct. 27, 2020, 1:16 p.m.