madanstat / LongCART

0 stars 0 forks source link

ProfilePlot bug at line 75 #4

Open samvgon opened 7 months ago

samvgon commented 7 months ago

In the plotting code chunk at the end of ProfilePlot_08May2022.R, in this section:

for (sg.i in 1:n.sg) {
        crit <- Tout$yval[sg.i]
        fit.val <- with(profile.data, eval(parse(text = crit)))
        plot(profile.data$time, fit.val, type = "l", xlab = xlab, 
            ylab = ylab, main = Tout$main[sg.i], ylim = y.range, 
            ...)
    }

You used profile.data$time on line 75 of the function code or line 4 here, which causes errors when plotting x variables not explicitly named 'time'. I was able to run it on my case with the following modification:

for (sg.i in 1:n.sg) {
        crit <- Tout$yval[sg.i]
        fit.val <- with(profile.data, eval(parse(text = crit)))
        plot(profile.data[[timevar]], fit.val, type = "l", xlab = xlab, 
            ylab = ylab, main = Tout$main[sg.i], ylim = y.range, 
            ...)
    }
madanstat commented 4 months ago

Thanks for taking time to share it. Noted the issue. Will be updated in the next version, and I will post here once it is updated. Thank you so much for providing the solution as well, which is very helpful and much appreciated.