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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Sep 15 16:24:51 CEST 2012


Author: gsee
Date: 2012-09-15 16:24:51 +0200 (Sat, 15 Sep 2012)
New Revision: 1184

Modified:
   pkg/FinancialInstrument/DESCRIPTION
   pkg/FinancialInstrument/R/CompareInstrumentFiles.R
   pkg/FinancialInstrument/man/CompareInstrumentFiles.Rd
Log:
 if only one file is provided to CompareInstrumentFiles, the currently loaded .instrument environment will be compared against it.

Modified: pkg/FinancialInstrument/DESCRIPTION
===================================================================
--- pkg/FinancialInstrument/DESCRIPTION	2012-09-15 13:13:47 UTC (rev 1183)
+++ pkg/FinancialInstrument/DESCRIPTION	2012-09-15 14:24:51 UTC (rev 1184)
@@ -9,7 +9,7 @@
     Ulrich, Brian G. Peterson, Garrett See
 Description: Infrastructure for defining meta-data and
     relationships for financial instruments.
-Version: 1.0.2
+Version: 1.0.3
 URL: https://r-forge.r-project.org/projects/blotter/
 Date: $Date$
 Depends:

Modified: pkg/FinancialInstrument/R/CompareInstrumentFiles.R
===================================================================
--- pkg/FinancialInstrument/R/CompareInstrumentFiles.R	2012-09-15 13:13:47 UTC (rev 1183)
+++ pkg/FinancialInstrument/R/CompareInstrumentFiles.R	2012-09-15 14:24:51 UTC (rev 1184)
@@ -10,7 +10,9 @@
 #' different.
 #'
 #' @param file1 A file containing an instrument environment
-#' @param file2 Another file containing an instrument environment
+#' @param file2 Another file containing an instrument environment.  If not 
+#'   provided, \code{file1} will be compared against the currently loaded 
+#'   instrument environment will be used
 #' @param ... Arguments to pass to \code{\link{all.equal.instrument}}
 #' @return A list that contains the names of all instruments that were added,
 #'   the names of all instruments that were removed, and the changes to all
@@ -40,17 +42,19 @@
 #' }
 #' @export
 CompareInstrumentFiles <- function(file1, file2, ...) {
-    force(file1); force(file2)
-    stopifnot(require("FinancialInstrument"))
+    force(file1)
     #backup current instrument environment
     bak <- as.list(FinancialInstrument:::.instrument, all.names=TRUE)
     # load files to be compared
     reloadInstruments(file1)
     orig <- as.list(FinancialInstrument:::.instrument, all.names=TRUE)
-    reloadInstruments(file2)
-    new <-  as.list(FinancialInstrument:::.instrument, all.names=TRUE)
-    #restore user's instrument environment
-    reloadInstruments(bak)
+    if (!missing(file2)) {
+        force(file2)
+        reloadInstruments(file2)
+        new <- as.list(FinancialInstrument:::.instrument, all.names=TRUE)
+        #restore user's instrument environment
+        reloadInstruments(bak)
+    } else new <- bak
     new.instruments <- names(new)[!names(new) %in% names(orig)]
     removed.instruments <- names(orig)[!names(orig) %in% names(new)]
     lni <- length(new.instruments)

Modified: pkg/FinancialInstrument/man/CompareInstrumentFiles.Rd
===================================================================
--- pkg/FinancialInstrument/man/CompareInstrumentFiles.Rd	2012-09-15 13:13:47 UTC (rev 1183)
+++ pkg/FinancialInstrument/man/CompareInstrumentFiles.Rd	2012-09-15 14:24:51 UTC (rev 1184)
@@ -8,7 +8,9 @@
   \item{file1}{A file containing an instrument environment}
 
   \item{file2}{Another file containing an instrument
-  environment}
+  environment.  If not provided, \code{file1} will be
+  compared against the currently loaded instrument
+  environment will be used}
 
   \item{...}{Arguments to pass to
   \code{\link{all.equal.instrument}}}



More information about the Blotter-commits mailing list