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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Aug 29 03:10:00 CEST 2012


Author: gsee
Date: 2012-08-29 03:09:58 +0200 (Wed, 29 Aug 2012)
New Revision: 1145

Modified:
   pkg/FinancialInstrument/DESCRIPTION
   pkg/FinancialInstrument/R/ls_instruments_by.R
Log:
 check is.na to avoid error when an attribute is NA.  This function's code could be simplified.

Modified: pkg/FinancialInstrument/DESCRIPTION
===================================================================
--- pkg/FinancialInstrument/DESCRIPTION	2012-08-29 00:29:07 UTC (rev 1144)
+++ pkg/FinancialInstrument/DESCRIPTION	2012-08-29 01:09:58 UTC (rev 1145)
@@ -9,7 +9,7 @@
     Ulrich, Brian G. Peterson, Garrett See
 Description: Infrastructure for defining meta-data and 
     relationships for financial instruments.
-Version: 1.0.1
+Version: 1.0.2
 URL: https://r-forge.r-project.org/projects/blotter/
 Date: $Date$
 Depends:

Modified: pkg/FinancialInstrument/R/ls_instruments_by.R
===================================================================
--- pkg/FinancialInstrument/R/ls_instruments_by.R	2012-08-29 00:29:07 UTC (rev 1144)
+++ pkg/FinancialInstrument/R/ls_instruments_by.R	2012-08-29 01:09:58 UTC (rev 1145)
@@ -63,12 +63,22 @@
             if (
                 if (is.null(value)) { #ls_instruments_by('type',NULL) or ls_instruments_by('name',NULL,'src')
                     if (is.null(in.slot)) { #ls_instruments_by('type',NULL) -- all instruments that have a 'type' element
-                        if (!inherits(try(tmp_instr[[what]],silent=TRUE), 'try-error') && !is.null(tmp_instr[[what]])) {TRUE} else {FALSE}
-                    } else if (!inherits(try(tmp_instr[[in.slot]][[what]],silent=TRUE), 'try-error') && !is.null(tmp_instr[[in.slot]][[what]])) {TRUE} else {FALSE}
+                        if (!inherits(try(tmp_instr[[what]],silent=TRUE), 
+                                      'try-error') && 
+                            !is.na(tmp_instr[[what]]) && 
+                            !is.null(tmp_instr[[what]])) {TRUE} else {FALSE}
+                    } else if (!inherits(try(tmp_instr[[in.slot]][[what]],
+                                             silent=TRUE), 'try-error') && 
+                        !is.na(tmp_instr[[in.slot]][[what]]) && 
+                        !is.null(tmp_instr[[in.slot]][[what]])) {TRUE} else {FALSE}
                 } else if (is.null(in.slot)) {
-                    if (!is.null(tmp_instr[[what]]) && any(tmp_instr[[what]] == value) ) {TRUE} else {FALSE}
+                    if (!is.null(tmp_instr[[what]]) && 
+                        !is.na(tmp_instr[[what]]) && 
+                        any(tmp_instr[[what]] == value) ) {TRUE} else {FALSE}
                 } else { #!is.null(value) && !is.null(in.slot)
-                    if (!is.null(tmp_instr[[in.slot]][[what]]) && any(tmp_instr[[in.slot]][[what]] == value)) {TRUE} else {FALSE}
+                    if (!is.null(tmp_instr[[in.slot]][[what]]) && 
+                        !is.na(tmp_instr[[in.slot]][[what]]) && 
+                        any(tmp_instr[[in.slot]][[what]] == value)) {TRUE} else {FALSE}
                 }
             ) tmp_symbols <- c(tmp_symbols, symbol)
         }    



More information about the Blotter-commits mailing list