我正在努力使以下功能正常工作,但却出错:
> mynomogram
function(sfstr, mydf){
sf = as.formula(sfstr)
library(rms)
mod = ols(sf, mydf)
dd = datadist(mydf)
options(datadist='dd')
plot(nomogram(mod))
}
>
> mynomogram('mpg~disp+hp+cyl', mtcars)
Error in value.chk(at, i, NA, -nint, Limval, type.range = "full") :
variable disp does not have limits defined by datadist
>
> mynomogram('mpg~disp+hp+cyl', mtcars)
Error in Design(X) : dataset dd not found for options(datadist=)
错误在哪里以及如何解决?谢谢你的帮助。
答案 0 :(得分:3)
使用dd <<-datadist(mydf)