harrelfe / rms

Regression Modeling Strategies
https://hbiostat.org/R/rms
Other
172 stars 48 forks source link

add envir to Predict to make it working if used in another function #81

Closed slzhao closed 3 years ago

slzhao commented 4 years ago

minor change to Predict to make it working if used in another function. Example code:

library(rms)
rawData=data.frame(a=rep(c(0,1),5),b=rnorm(10))
ddist = datadist(rawData)
options(datadist='ddist')

##Not working before change, working after change
test=function(rawData) {
  f <- lrm(a ~ b,data=rawData)
  result=Predict(f)
  print(plot(result))
}

test(rawData)

##Error message before change
##Error in Predict(x = f, name = "b") : object 'f' not found
##Calls: test -> Predict -> eval -> eval -> Predict
harrelfe commented 3 years ago

You have made more changes than what you indicated in the description (which relates only to Predict). This is confusing.

slzhao commented 3 years ago

The change to Predict function is already in latest rms (rms_6.2-0). Other changes are related to my minor changes to set different colors to the lines in calibrate plot to distinguish them and should not be included in this pull request. I will close this pull request. Thanks Frank!