@@ -465,8 +465,8 @@ FDboost <- function(formula, ### response ~ xvars
465465 # # check if number of opening brackets is equal to number of closing brackets
466466 equalBrackets <- sapply(seq_along(trmstrings2 ), function (i )
467467 {
468- lengths(regmatches(trmstrings2 [i ], gregexpr(" \\ (" , trmstrings2 [i ]))) ==
469- lengths(regmatches(trmstrings2 [i ], gregexpr(" \\ )" , trmstrings2 [i ])))
468+ lengths(regmatches(trmstrings2 [i ], gregexpr(" (" , trmstrings2 [i ], fixed = TRUE ))) ==
469+ lengths(regmatches(trmstrings2 [i ], gregexpr(" )" , trmstrings2 [i ], fixed = TRUE )))
470470 })
471471 }
472472
@@ -486,8 +486,8 @@ FDboost <- function(formula, ### response ~ xvars
486486 if (length(trmstrings ) > 0 ){
487487 # # insert index into the other base-learners of the tensor-product as well
488488 for (i in seq_along(trmstrings )){
489- if (grepl( " %X" , trmstrings2 [i ])){
490- temp <- unlist(strsplit(trmstrings2 [i ], " %X" ))
489+ if (grepl( " %X" , trmstrings2 [i ], fixed = TRUE )){
490+ temp <- unlist(strsplit(trmstrings2 [i ], " %X" , fixed = TRUE ))
491491 temp1 <- temp [- length(temp )]
492492 # # http://stackoverflow.com/questions/2261079
493493 # # delete all trailing whitespace
@@ -497,13 +497,13 @@ FDboost <- function(formula, ### response ~ xvars
497497 trmstrings2 [i ] <- paste0(paste0(temp1 , collapse = " %X" ), " %X" , temp [length(temp )])
498498 }
499499 # # do not add index to base-learners bhistx()
500- if ( grepl(" bhistx" , trmstrings [i ]) ) trmstrings2 [i ] <- trmstrings [i ]
500+ if ( grepl(" bhistx" , trmstrings [i ], fixed = TRUE ) ) trmstrings2 [i ] <- trmstrings [i ]
501501 # # do not add an index if an index is already part of the formula
502502 if ( grepl(" index[[:blank:]]*=" , trmstrings [i ]) ) trmstrings2 [i ] <- trmstrings [i ]
503503 # # do not add an index if an index for %A%, %A0%, %O%
504- if ( grepl(" %A%" , trmstrings [i ]) ) trmstrings2 [i ] <- trmstrings [i ]
505- if ( grepl(" %A0%" , trmstrings [i ]) ) trmstrings2 [i ] <- trmstrings [i ]
506- if ( grepl(" %O%" , trmstrings [i ]) ) trmstrings2 [i ] <- trmstrings [i ]
504+ if ( grepl(" %A%" , trmstrings [i ], fixed = TRUE ) ) trmstrings2 [i ] <- trmstrings [i ]
505+ if ( grepl(" %A0%" , trmstrings [i ], fixed = TRUE ) ) trmstrings2 [i ] <- trmstrings [i ]
506+ if ( grepl(" %O%" , trmstrings [i ], fixed = TRUE ) ) trmstrings2 [i ] <- trmstrings [i ]
507507 # # do not add an index for base-learner that do not have brackets
508508 if ( i %in% which(! equalBrackets ) ) trmstrings2 [i ] <- trmstrings [i ]
509509 }
@@ -538,7 +538,7 @@ FDboost <- function(formula, ### response ~ xvars
538538 scalarResponse <- TRUE
539539 if (is.null(timeformula )) scalarNoFLAM <- TRUE
540540
541- if (grepl(" df" , formula [3 ]) || ! grepl(" lambda" , formula [3 ]) ){
541+ if (grepl(" df" , formula [3 ], fixed = TRUE ) || ! grepl(" lambda" , formula [3 ], fixed = TRUE ) ){
542542 timeformula <- ~ bols(ONEtime , intercept = FALSE , df = 1 )
543543 }else {
544544 timeformula <- ~ bols(ONEtime , intercept = FALSE )
@@ -671,23 +671,23 @@ FDboost <- function(formula, ### response ~ xvars
671671
672672 # # get formula over time
673673 tfm <- paste(deparse(timeformula ), collapse = " " )
674- tfm <- strsplit(tfm , " ~" )[[1 ]]
675- tfm <- strsplit(tfm [2 ], " \\ + " )[[1 ]]
674+ tfm <- strsplit(tfm , " ~" , fixed = TRUE )[[1 ]]
675+ tfm <- strsplit(tfm [2 ], " + " , fixed = TRUE )[[1 ]]
676676
677677 # # get formula in covariates
678678 cfm <- paste(deparse(formula ), collapse = " " )
679- cfm <- strsplit(cfm , " ~" )[[1 ]]
679+ cfm <- strsplit(cfm , " ~" , fixed = TRUE )[[1 ]]
680680 cfm0 <- cfm
681681 # xfm <- strsplit(cfm[2], "\\+")[[1]]
682682 xfm <- trmstrings
683683
684684 # # check that the timevariable in timeformula and in the bhistx-base-learners have the same name
685- if (any(grepl(" bhistx" , trmstrings ))){
685+ if (any(grepl(" bhistx" , trmstrings , fixed = TRUE ))){
686686 for (j in seq_along(trmstrings )){
687- if (any(grepl(" bhistx" , trmstrings [j ]))){
688- if (grepl(" %X" , trmstrings [j ]) ){
687+ if (any(grepl(" bhistx" , trmstrings [j ], fixed = TRUE ))){
688+ if (grepl(" %X" , trmstrings [j ], fixed = TRUE ) ){
689689 temp <- strsplit(trmstrings [[j ]], " %X.*%" )[[1 ]]
690- temp <- temp [ grepl(" bhistx" , temp ) ]
690+ temp <- temp [ grepl(" bhistx" , temp , fixed = TRUE ) ]
691691 # # pryr::standardise_call(quote(bhistx(X1h, df=3)))
692692 temp_name <- all.vars(formula(paste(" ~" , temp )))[1 ]
693693 }else {
@@ -707,13 +707,13 @@ FDboost <- function(formula, ### response ~ xvars
707707 }
708708 }
709709
710- yfm <- strsplit(cfm [1 ], " \\ + " )[[1 ]] # # name of response
710+ yfm <- strsplit(cfm [1 ], " + " , fixed = TRUE )[[1 ]] # # name of response
711711
712712 # # set up formula for effects constant in time
713713 if (length(where.c ) > 0 ){
714714 # set c_df to the df/lambda in timeformula
715- if ( grepl(" lambda" , tfm ) ||
716- ( grepl(" bols" , tfm ) && ! grepl(" df" , tfm )) ){
715+ if ( grepl(" lambda" , tfm , fixed = TRUE ) ||
716+ ( grepl(" bols" , tfm , fixed = TRUE ) && ! grepl(" df" , tfm , fixed = TRUE )) ){
717717 c_lambda <- eval(parse(text = paste0(tfm , " $dpp(rep(1.0," , length(time ), " ))$df()" )))[" lambda" ]
718718 cfm <- paste(" bols(ONEtime, intercept = FALSE, lambda = " , c_lambda ," )" )
719719 } else {
@@ -745,20 +745,20 @@ FDboost <- function(formula, ### response ~ xvars
745745 }
746746
747747 # do not expand an effect bconcurrent() or bhist() with timeformula
748- if ( length(c(grep (" bconcurrent" , tmp ), grep( " bhis" , tmp )) ) > 0 )
749- tmp [c(grep(" bconcurrent" , tmp ), grep(" bhist" , tmp ))] <- xfm [c(grep(" bconcurrent" , tmp ), grep(" bhist" , tmp ))]
748+ if (any(grepl (" bconcurrent| bhis" , tmp )))
749+ tmp [c(grep(" bconcurrent" , tmp , fixed = TRUE ), grep(" bhist" , tmp , fixed = TRUE ))] <- xfm [c(grep(" bconcurrent" , tmp , fixed = TRUE ), grep(" bhist" , tmp , fixed = TRUE ))]
750750
751751 # # do not expand effects in formula including %A% with timeformula
752- if ( length(grep (" %A%" , xfm )) > 0 )
753- tmp [grep(" %A%" , xfm )] <- xfm [grep(" %A%" , xfm )]
752+ if ( any(grepl (" %A%" , xfm , fixed = TRUE )) )
753+ tmp [grep(" %A%" , xfm , fixed = TRUE )] <- xfm [grep(" %A%" , xfm , fixed = TRUE )]
754754
755755 # # do not expand effects in formula including %A0% with timeformula
756- if ( length(grep (" %A0%" , xfm )) > 0 )
757- tmp [grep(" %A0%" , xfm )] <- xfm [grep(" %A0%" , xfm )]
756+ if ( any(grepl (" %A0%" , xfm , fixed = TRUE )) )
757+ tmp [grep(" %A0%" , xfm , fixed = TRUE )] <- xfm [grep(" %A0%" , xfm , fixed = TRUE )]
758758
759759 # # do not expand effects in formula including %O% with timeformula
760- if ( length(grep (" %O%" , xfm )) > 0 )
761- tmp [grep(" %O%" , xfm )] <- xfm [grep(" %O%" , xfm )]
760+ if ( any(grepl (" %O%" , xfm , fixed = TRUE )) )
761+ tmp [grep(" %O%" , xfm , fixed = TRUE )] <- xfm [grep(" %O%" , xfm , fixed = TRUE )]
762762
763763 # # expand with a constant effect in t-direction
764764 if (length(where.c ) > 0 ){
@@ -833,11 +833,11 @@ FDboost <- function(formula, ### response ~ xvars
833833
834834 # ## replace "1" with intercept base learner
835835 formula_intercept <- FALSE
836- if ( any( gsub(" " , " " , strsplit(cfm0 [2 ], " \\ + " )[[1 ]]) == " 1" )){
836+ if ( any( gsub(" " , " " , strsplit(cfm0 [2 ], " + " , fixed = TRUE )[[1 ]], fixed = TRUE ) == " 1" )){
837837 formula_intercept <- TRUE
838838 # # use df or lambda as in timeformula
839- if ( any(grepl(" lambda" , deparse(timeformula ))) ||
840- any(( grepl(" bols" , deparse(timeformula )) & ! grepl(" df" , deparse(timeformula )))) ){
839+ if ( any(grepl(" lambda" , deparse(timeformula ), fixed = TRUE )) ||
840+ any(( grepl(" bols" , deparse(timeformula ), fixed = TRUE ) & ! grepl(" df" , deparse(timeformula ), fixed = TRUE ))) ){
841841 tmp <- c(" bols(ONEx, intercept = FALSE, lambda = 0)" , tmp )
842842 } else {
843843 tmp <- c(" bols(ONEx, intercept = FALSE, df = 1)" , tmp )
@@ -879,9 +879,9 @@ FDboost <- function(formula, ### response ~ xvars
879879 # # get the limits argument
880880 current_bl <- attr(terms_fm_bhist , " variables" )[[places_bhist [pl ] + 1 ]]
881881 # for base-learner with interaction, find bhistx / bhist
882- if (any(grepl(" %X" , current_bl ))){
882+ if (any(grepl(" %X" , current_bl , fixed = TRUE ))){
883883 # current_bl <- current_bl[ grepl("bhist", current_bl) ]
884- arg_limits <- eval(as.call(as.list(current_bl [grepl(" bhist" , current_bl )])[[1 ]])$ limits )
884+ arg_limits <- eval(as.call(as.list(current_bl [grepl(" bhist" , current_bl , fixed = TRUE )])[[1 ]])$ limits )
885885 }else {
886886 # limits argument of bhist / bhistx
887887 arg_limits <- eval(as.call(current_bl )$ limits )
@@ -1163,7 +1163,7 @@ FDboost <- function(formula, ### response ~ xvars
11631163 if (check0 && length(ret $ baselearner ) > 1 && is.null(id ) && dim(response )[2 ] != 1 ){
11641164
11651165 # do not check the smooth intercept
1166- if (any( gsub(" " , " " , strsplit(cfm [2 ], " \\ + " )[[1 ]]) == " 1" )){
1166+ if (any( gsub(" " , " " , strsplit(cfm [2 ], " + " , fixed = TRUE )[[1 ]], fixed = TRUE ) == " 1" )){
11671167 effectsToCheck <- 2 : length(ret $ baselearner )
11681168 }else {
11691169 effectsToCheck <- seq_along(ret $ baselearner )
0 commit comments