R/remap.event.reindex.R

Defines functions remap.event.reindex

Documented in remap.event.reindex

# A function which consumes a zoo object where there are lots of events
# (as columns)
# The contents are all levels
# For each column, the event date value is set to 100 and all other
# values are scaled accordingly.
remap.event.reindex <- function(z) {
  eventvals <- as.numeric(window(z, start=0, end=0))
  for (i in 1:NCOL(z)) {
    if(NCOL(z)==1){
      z <- 100*z[,i]/eventvals[i]
    } else {
      z[,i] <- 100*z[,i]/eventvals[i]
    }
  }
  z
}

Try the eventstudies package in your browser

Any scripts or data that you put into this service are public.

eventstudies documentation built on July 1, 2020, 10:26 p.m.