[Blotter-commits] r257 - pkg/quantstrat/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 24 16:22:11 CET 2010


Author: braverock
Date: 2010-02-24 16:22:11 +0100 (Wed, 24 Feb 2010)
New Revision: 257

Modified:
   pkg/quantstrat/R/match.names.R
Log:
- reverse argument order to match order of 'grep'

Modified: pkg/quantstrat/R/match.names.R
===================================================================
--- pkg/quantstrat/R/match.names.R	2010-02-24 15:17:54 UTC (rev 256)
+++ pkg/quantstrat/R/match.names.R	2010-02-24 15:22:11 UTC (rev 257)
@@ -13,10 +13,12 @@
 #' @param data_names names for the data to be matched to
 #' @param match_names names to match
 #' @export
-match.names <- function(data_names,match_names) {
-    loc<-vector()
+match.names <- function(match_names,data_names) {
+    loc<-NULL
     for (mname in match_names){
-        loc <- c(loc,grep(mname,data_names))
+        t<-grep(mname,data_names)
+        if(is.null(loc)) loc<-t
+        else loc <- c(loc,t)
     }
     if ( !identical(length(loc),length(match_names)) ) {
         mstr<-paste(match_names,collapse=' ')



More information about the Blotter-commits mailing list