@@ -248,7 +248,7 @@ applyFolds <- function(object, folds = cv(rep(1, length(unique(object$id))), typ
248248 # # problem with index for bl containing index, and you do not get s for bsignal/bhist
249249 if (FALSE ){
250250 dathelp2 <- list ()
251- for (j in 1 : length (object $ baselearner )){
251+ for (j in seq_along (object $ baselearner )){
252252 dat_bl_j <- object $ baselearner [[j ]]$ get_data() # # object$baselearner[[j]]$model.frame()
253253 # if the variable is already present, do not add it again
254254 dathelp2 <- c(dathelp2 , dat_bl_j [! names(dat_bl_j ) %in% names(dathelp2 )])
@@ -317,7 +317,7 @@ applyFolds <- function(object, folds = cv(rep(1, length(unique(object$id))), typ
317317
318318 # for each missing variable get the first baselearner, which contains the variable
319319 blWithMissVars <- lapply(names_variables [whMiss ], function (w )
320- unlist(lapply(1 : length (object $ baselearner ), function (i ) if (
320+ unlist(lapply(seq_along (object $ baselearner ), function (i ) if (
321321 any( grepl(w , object $ baselearner [[i ]]$ get_names() ) )) return (i ))
322322 )[1 ])
323323
@@ -352,7 +352,7 @@ applyFolds <- function(object, folds = cv(rep(1, length(unique(object$id))), typ
352352 if (any(isFac )){
353353 namesFac <- names(isFac )[isFac ]
354354
355- for (i in 1 : length (namesFac )){
355+ for (i in seq_along (namesFac )){
356356
357357 if (length(levels(droplevels(dathelp [[namesFac [i ]]]))) !=
358358 length(levels(droplevels(dat_weights [[namesFac [i ]]]))))
@@ -963,11 +963,11 @@ validateFDboost <- function(object, response = NULL,
963963 oobpreds <- matrix (nrow = nrow(oobpreds0 [[1 ]]), ncol = ncol(oobpreds0 [[1 ]]))
964964
965965 if (any(class(object ) == " FDboostLong" )){
966- for (i in 1 : length (oobpreds0 )){ # i runs over observed trajectories, i.e. over id
966+ for (i in seq_along (oobpreds0 )){ # i runs over observed trajectories, i.e. over id
967967 oobpreds [id == i , ] <- oobpreds0 [[i ]][id == i , ]
968968 }
969969 }else {
970- for (j in 1 : length (oobpreds0 )){
970+ for (j in seq_along (oobpreds0 )){
971971 oobpreds [folds [ , j ] == 0 ] <- oobpreds0 [[j ]][folds [ , j ] == 0 ]
972972 }
973973 }
@@ -1008,7 +1008,7 @@ validateFDboost <- function(object, response = NULL,
10081008
10091009 # ## estimates of coefficients
10101010 timeHelp <- seq(min(modRisk [[1 ]]$ mod $ yind ), max(modRisk [[1 ]]$ mod $ yind ), l = 40 )
1011- for (l in 1 : length (modRisk [[1 ]]$ mod $ baselearner )){
1011+ for (l in seq_along (modRisk [[1 ]]$ mod $ baselearner )){
10121012 # estimate the coefficients for the model of the first fold
10131013 my_coef <- coef(modRisk [[1 ]]$ mod [optimalMstop ],
10141014 which = l , n1 = 40 , n2 = 20 , n3 = 15 , n4 = 10 )$ smterms [[1 ]]
@@ -1023,7 +1023,7 @@ validateFDboost <- function(object, response = NULL,
10231023 attr(coefCV [[l ]]$ value , " offset" ) <- NULL # as offset is the same within one model
10241024
10251025 # add estimates for the models of the other folds
1026- coefCV [[l ]]$ value <- lapply(1 : length (modRisk ), function (g ){
1026+ coefCV [[l ]]$ value <- lapply(seq_along (modRisk ), function (g ){
10271027 ret <- coef(modRisk [[g ]]$ mod [optimalMstop ],
10281028 which = l , n1 = 40 , n2 = 20 , n3 = 15 , n4 = 10 )$ smterms [[1 ]]$ value
10291029 # if(l==1){
@@ -1036,7 +1036,7 @@ validateFDboost <- function(object, response = NULL,
10361036 # # %X% with numberLevels coefficient values in a list
10371037 # # lapply(1:coefCV[[l]]$numberLevels, function(x) coefCV[[l]][[x]]$value)
10381038 for (j in 1 : coefCV [[l ]]$ numberLevels ){
1039- coefCV [[l ]][[j ]]$ value <- lapply(1 : length (modRisk ), function (g ){
1039+ coefCV [[l ]][[j ]]$ value <- lapply(seq_along (modRisk ), function (g ){
10401040 ret <- coef(modRisk [[g ]]$ mod [optimalMstop ],
10411041 which = l , n1 = 40 , n2 = 20 , n3 = 15 , n4 = 10 )$ smterms [[1 ]][[j ]]$ value
10421042 attr(ret , " offset" ) <- NULL # as offset is the same within one model
@@ -1048,7 +1048,7 @@ validateFDboost <- function(object, response = NULL,
10481048 }
10491049
10501050 # # predict offset
1051- offset <- sapply(1 : length (modRisk ), function (g ){
1051+ offset <- sapply(seq_along (modRisk ), function (g ){
10521052 # offset is vector of length yind or numeric of length 1 for constant offset
10531053 ret <- modRisk [[g ]]$ mod $ predictOffset(time = timeHelp )
10541054 if ( length(ret ) == 1 & length(object $ yind ) > 1 ) ret <- rep(ret , length(timeHelp ))
@@ -1063,7 +1063,7 @@ validateFDboost <- function(object, response = NULL,
10631063 # only makes sense for type="curves" with leaving-out one curve per fold!!
10641064 if (grepl(" curves" , type )){
10651065 for (l in 1 : (length(modRisk [[1 ]]$ mod $ baselearner )+ 1 )){
1066- predCV [[l ]] <- t(sapply(1 : length (modRisk ), function (g ){
1066+ predCV [[l ]] <- t(sapply(seq_along (modRisk ), function (g ){
10671067 if (l == 1 ){ # save offset of model
10681068 # offset is vector of length yind or numeric of length 1 for constant offset
10691069 ret <- modRisk [[g ]]$ mod [optimalMstop ]$ predictOffset(object $ yind )
@@ -1356,7 +1356,7 @@ plotPredCoef <- function(x, which = NULL, pers = TRUE,
13561356
13571357 stopifnot(any(class(x ) == " validateFDboost" ))
13581358
1359- if (is.null(which )) which <- 1 : length (x $ coefCV )
1359+ if (is.null(which )) which <- seq_along (x $ coefCV )
13601360
13611361 oldpar <- par(no.readonly = TRUE )
13621362 on.exit(par(oldpar ))
@@ -1365,7 +1365,7 @@ plotPredCoef <- function(x, which = NULL, pers = TRUE,
13651365
13661366 if (terms ){
13671367
1368- if (all(which == 1 : length (x $ coefCV ))){
1368+ if (all(which == seq_along (x $ coefCV ))){
13691369 which <- 1 : (length(x $ coefCV )+ 1 )
13701370 }else {
13711371 which <- which + 1
@@ -1387,7 +1387,7 @@ plotPredCoef <- function(x, which = NULL, pers = TRUE,
13871387
13881388 funplot(x $ yind , unlist(x $ predCV [[l ]]), id = x $ id , col = " white" ,
13891389 main = names(x $ predCV )[l ], xlab = attr(x $ yind , " nameyind" ), ylab = " coef" , ylim = ylim , ... )
1390- for (i in 1 : length (x $ predCV [[l ]])){
1390+ for (i in seq_along (x $ predCV [[l ]])){
13911391 lines(x $ yind [x $ id == i ], x $ predCV [[l ]][[i ]], lwd = 1 , col = i )
13921392 if (showNumbers ){
13931393 points(x $ yind [x $ id == i ], x $ predCV [[l ]][[i ]], type = " p" , pch = paste0(i ))
@@ -1562,7 +1562,7 @@ plot_bootstrapped_coef <- function(temp, l,
15621562
15631563 # set lower triangular matrix to NA for historic effect
15641564 if (grepl(" bhist" , temp $ main )){
1565- for (k in 1 : length (temp $ value )){
1565+ for (k in seq_along (temp $ value )){
15661566 temp $ value [[k ]][temp $ value [[k ]]== 0 ] <- NA
15671567 }
15681568 }
@@ -1575,7 +1575,7 @@ plot_bootstrapped_coef <- function(temp, l,
15751575 # plot coefficient surfaces at different pointwise quantiles
15761576 if (pers ){
15771577 matvec <- sapply(temp $ value , c )
1578- for (k in 1 : length (probs )){
1578+ for (k in seq_along (probs )){
15791579
15801580 tempZ <- matrix (apply(matvec , 1 , quantile , probs = probs [k ], na.rm = TRUE ), ncol = length(temp $ x ))
15811581
@@ -1592,7 +1592,7 @@ plot_bootstrapped_coef <- function(temp, l,
15921592
15931593 }else { # do 2-dim plots
15941594
1595- # for(j in 1:length (quanty)){
1595+ # for(j in seq_along (quanty)){
15961596 #
15971597 # myCol <- sapply(temp$value, function(x) x[, quanty[j]==temp$y]) # first column
15981598 #
@@ -1602,7 +1602,7 @@ plot_bootstrapped_coef <- function(temp, l,
16021602 #
16031603 # } # end loop over quanty
16041604 #
1605- # for(j in 1:length (quantx)){
1605+ # for(j in seq_along (quantx)){
16061606 # myRow <- sapply(temp$value, function(x) x[quantx[j]==temp$x, ]) # first column
16071607 #
16081608 # plot_curves(x_i = temp$x, y_i = myRow, xlab_i = temp$xlab,
@@ -1612,7 +1612,7 @@ plot_bootstrapped_coef <- function(temp, l,
16121612 # }
16131613
16141614 matvec <- sapply(temp $ value , c )
1615- for (k in 1 : length (probs )){
1615+ for (k in seq_along (probs )){
16161616
16171617 tempZ <- matrix (apply(matvec , 1 , quantile , probs = probs [k ], na.rm = TRUE ), ncol = length(temp $ x ))
16181618
@@ -1633,7 +1633,7 @@ plot_bootstrapped_coef <- function(temp, l,
16331633
16341634 }else { # temp$x is factor
16351635
1636- for (j in 1 : length (quantx )){
1636+ for (j in seq_along (quantx )){
16371637
16381638 # impute matrix of 0 if effect was never chosen
16391639 temp $ value [sapply(temp $ value , function (x ) is.null(dim(x )))] <- list (matrix (0 , ncol = 20 , nrow = length(quantx )))
0 commit comments