[Blotter-commits] r745 - in pkg/FinancialInstrument: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Aug 27 20:00:06 CEST 2011


Author: bodanker
Date: 2011-08-27 20:00:06 +0200 (Sat, 27 Aug 2011)
New Revision: 745

Added:
   pkg/FinancialInstrument/man/print.instrument.Rd
Modified:
   pkg/FinancialInstrument/NAMESPACE
   pkg/FinancialInstrument/R/instrument.R
Log:
- added print method for instrument class


Modified: pkg/FinancialInstrument/NAMESPACE
===================================================================
--- pkg/FinancialInstrument/NAMESPACE	2011-08-26 04:31:19 UTC (rev 744)
+++ pkg/FinancialInstrument/NAMESPACE	2011-08-27 18:00:06 UTC (rev 745)
@@ -45,3 +45,4 @@
 export(synthetic.ratio)
 export(.to_daily)
 export(volep)
+S3method(print,instrument)

Modified: pkg/FinancialInstrument/R/instrument.R
===================================================================
--- pkg/FinancialInstrument/R/instrument.R	2011-08-26 04:31:19 UTC (rev 744)
+++ pkg/FinancialInstrument/R/instrument.R	2011-08-27 18:00:06 UTC (rev 745)
@@ -615,3 +615,26 @@
     assign(primary_id, instr, pos=.instrument)
 }
 
+#' instrument class print method
+#' 
+#' @method print instrument
+#' @S3method print instrument
+#' @keywords internal
+print.instrument <- function(x, ...) {
+  max.name <- max(sapply(names(x), nchar), na.rm=TRUE) + 1
+  for(i in seq_along(x)) {
+    xi <- unlist(x[[i]])
+    nx <- names(x)
+    nxi <- names(xi)
+    if(!is.null(nxi)) {
+      fxi <- format(rbind(nxi,xi))
+      cat(encodeString(nx[i], width=max.name), noquote(fxi[1,]), "\n")
+      cat(encodeString("",    width=max.name), noquote(fxi[2,]), "\n")
+    } else {
+      if(is.null(xi)) xi <- "NULL"
+      cat(encodeString(nx[i], width=max.name), noquote(xi), "\n")
+    }
+  }
+  invisible(x)
+}
+

Added: pkg/FinancialInstrument/man/print.instrument.Rd
===================================================================
--- pkg/FinancialInstrument/man/print.instrument.Rd	                        (rev 0)
+++ pkg/FinancialInstrument/man/print.instrument.Rd	2011-08-27 18:00:06 UTC (rev 745)
@@ -0,0 +1,11 @@
+\name{print.instrument}
+\alias{print.instrument}
+\title{instrument class print method}
+\usage{
+  \method{print}{instrument} (x, ...)
+}
+\description{
+  instrument class print method
+}
+\keyword{internal}
+



More information about the Blotter-commits mailing list