[Eventstudies-commits] r350 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 15 21:16:22 CEST 2014


Author: chiraganand
Date: 2014-05-15 21:16:21 +0200 (Thu, 15 May 2014)
New Revision: 350

Modified:
   pkg/R/phys2eventtime.R
Log:
Fixed bug related to order of when and name columns.

Modified: pkg/R/phys2eventtime.R
===================================================================
--- pkg/R/phys2eventtime.R	2014-05-15 18:44:20 UTC (rev 349)
+++ pkg/R/phys2eventtime.R	2014-05-15 19:16:21 UTC (rev 350)
@@ -24,16 +24,16 @@
   }
 
   timeshift <- function(x) {
-    firm.present <- match(x[1], colnames(z), nomatch = -1) != -1
+    firm.present <- match(x["name"], colnames(z), nomatch = -1) != -1
     if (!firm.present) {
       return(list(result=NULL, outcome="unitmissing"))
     }
     ## Take previous date if exact data is not found.
-    location <- findInterval(as.Date(x[2]), index(z[, x[1]]))
+    location <- findInterval(as.Date(x["when"]), index(z[, x["name"]]))
     if ((location <= 1) | (location >= length(index(z)))) {
       return(list(result=NULL, outcome="wrongspan"))
     }
-    remapped <- zoo(as.numeric(z[,x[1]]), order.by=(-location+1):(length(z[,x[1]])-location))
+    remapped <- zoo(as.numeric(z[,x["name"]]), order.by=(-location+1):(length(z[,x["name"]])-location))
     return(list(result=remapped, outcome="success"))
   }
   



More information about the Eventstudies-commits mailing list