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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Sep 8 20:13:57 CEST 2012


Author: gsee
Date: 2012-09-08 20:13:56 +0200 (Sat, 08 Sep 2012)
New Revision: 1168

Added:
   pkg/FinancialInstrument/man/sort.instrument.Rd
Modified:
   pkg/FinancialInstrument/NAMESPACE
   pkg/FinancialInstrument/R/instrument.R
Log:
 add sort.instrument method

Modified: pkg/FinancialInstrument/NAMESPACE
===================================================================
--- pkg/FinancialInstrument/NAMESPACE	2012-09-08 15:13:16 UTC (rev 1167)
+++ pkg/FinancialInstrument/NAMESPACE	2012-09-08 18:13:56 UTC (rev 1168)
@@ -135,3 +135,4 @@
 S3method(print,id.list)
 S3method(print,instrument)
 S3method(print,suffix.list)
+S3method(sort,instrument)

Modified: pkg/FinancialInstrument/R/instrument.R
===================================================================
--- pkg/FinancialInstrument/R/instrument.R	2012-09-08 15:13:16 UTC (rev 1167)
+++ pkg/FinancialInstrument/R/instrument.R	2012-09-08 18:13:56 UTC (rev 1168)
@@ -1406,3 +1406,18 @@
   invisible(x)
 }
 
+#' instrument class sort method
+#' 
+#' @method sort instrument
+#' @S3method sort instrument
+#' @author Garrett See
+#' @keywords internal
+sort.instrument <- function(x, decreasing=FALSE, na.last=NA, ...) {
+    anchored <- x[c("primary_id", "currency", "multiplier", "tick_size", 
+                  "identifiers", "type")] 
+    sortable <- x[setdiff(names(x), names(anchored))]
+    out <- c(anchored, sortable[order(names(sortable), decreasing=decreasing, 
+                                      na.last=na.last, ...)])
+    class(out) <- class(x)
+    out
+}

Added: pkg/FinancialInstrument/man/sort.instrument.Rd
===================================================================
--- pkg/FinancialInstrument/man/sort.instrument.Rd	                        (rev 0)
+++ pkg/FinancialInstrument/man/sort.instrument.Rd	2012-09-08 18:13:56 UTC (rev 1168)
@@ -0,0 +1,15 @@
+\name{sort.instrument}
+\alias{sort.instrument}
+\title{instrument class sort method}
+\usage{
+  \method{sort}{instrument} (x, decreasing = FALSE,
+    na.last = NA, ...)
+}
+\description{
+  instrument class sort method
+}
+\author{
+  Garrett See
+}
+\keyword{internal}
+



More information about the Blotter-commits mailing list