[Eventstudies-commits] r334 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 15 01:40:06 CEST 2014


Author: chiraganand
Date: 2014-05-15 01:40:06 +0200 (Thu, 15 May 2014)
New Revision: 334

Modified:
   pkg/R/eventstudy.R
Log:
Moved the input args from the output list into attributes; modified print and plot functions accordingly.

Modified: pkg/R/eventstudy.R
===================================================================
--- pkg/R/eventstudy.R	2014-05-14 23:13:29 UTC (rev 333)
+++ pkg/R/eventstudy.R	2014-05-14 23:40:06 UTC (rev 334)
@@ -135,10 +135,14 @@
     result <- es.w
   }
   if(to.remap==TRUE){remapping <- remap} else {remapping <- "none"}
-    final.result <- list(eventstudy.output=result,
-                         outcomes=as.character(es$outcomes),
-                         inference=inference.strategy,
-                         width=width, remap=remapping)
+
+  final.result <- list(eventstudy.output = result,
+                       outcomes = as.character(es$outcomes))
+
+  attr(final.result, which = "inference") <- inference.strategy
+  attr(final.result, which = "width") <- width
+  attr(final.result, which = "remap") <- remapping
+
   class(final.result) <- "es"
   return(final.result)
 }
@@ -149,7 +153,7 @@
 
 print.es <- function(x, ...){
   cat("Event study", colnames(x$eventstudy.output)[2], "response with",
-      x$inference, "inference for CI:\n")
+      attr(x, "inference"), "inference for CI:\n")
   print(x$eventstudy.output)
   cat("\n","Event outcome has",length(which(x$outcomes=="success")),
       "successful outcomes out of", length(x$outcomes),"events:","\n")
@@ -171,11 +175,11 @@
 
   ## assign own labels if they're missing
   if (is.null(ylab)) {
-      if (x$remap == "cumsum") {
+      if (attr(x, "remap") == "cumsum") {
           remapLabel <- "Cum."
-      } else if (x$remap == "cumprod") {
+      } else if (attr(x, "remap") == "cumprod") {
           remapLabel <- "Cum. product"
-      } else if (x$remap == "reindex") {
+      } else if (attr(x, "remap") == "reindex") {
           remapLabel <- "Re-index"
       } else {
           remapLabel <- ""



More information about the Eventstudies-commits mailing list