tedwestling / survSuperLearner

Super learning of conditional survival functions with right-censored time-to-event outcomes in discrete or continuous time.
9 stars 6 forks source link

subset with 1-column data frames #6

Closed QIU-Hongxiang-David closed 1 year ago

QIU-Hongxiang-David commented 1 year ago

In some functions, when subsetting a data frame with only one column, drop=FALSE probably needs to be added to avoid getting a vector. For example, in the following call in the function survSL.weibreg:

fit.weibreg <- survival::survreg(survival::Surv(time[time > 0], event[time > 0]) ~ .,
                                  data = X[time > 0,],
                                  weights = obsWeights[time > 0], dist = 'weibull')

data = X[time > 0,] might need to be changed to data = X[time > 0, , drop = FALSE] to deal with the case where X is a data frame with only one column.

Similar issues might occur in other SL wrappers as well.

tedwestling commented 1 year ago

Thanks, I hopefully fixed this issue.