jthaman / ciTools

An R Package for Quick Uncertainty Intervals
GNU General Public License v3.0
106 stars 9 forks source link

Data not overwritten when rerunning add_ci #11

Closed aldaniello closed 6 years ago

aldaniello commented 6 years ago

If I run: test <- add_ci(test, testModel, alpha = 0.1, names = c(“LCB”, “UCB”)) test$pred <- NA test$LCB <- NA test$UCB <- NA

THEN: newDF <- add_ci(test, testModel, alpha = 0.1, names = c(“LCB”, “UCB”)) -or - test <- add_ci(test, testModel, alpha = 0.1, names = c(“LCB”, “UCB”))

Both the newDF and test dataframes come up with the columns still set to NA. This occurs with values in the columns too, not only after setting the columns to NA. It does not always occur on the first attempt, but once it occurs it continues to occur.

jthaman commented 6 years ago

Hello, Thank you for this issue! I have been able to reproduce this error.

jthaman commented 6 years ago

@matthewravery ,the reason this is occurring is because some methods have this block of code at the end

        if(is.null(tb[[yhatName]]))
            tb[[yhatName]] <- out[, 1]
        if (is.null(tb[[names[1]]]))
            tb[[names[1]]] <- out[, 2]
        if (is.null(tb[[names[2]]]))
            tb[[names[2]]] <- out[, 3]
matthewravery commented 6 years ago

The issue only occurred in two functions. It's been fixed.