0

I am trying to make following function work but it is giving errors:

> 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=)

Where is the error and how can it be solved? Thanks for your help.

rnso
  • 23,686
  • 25
  • 112
  • 234

1 Answers1

4

use dd <<- datadist(mydf)

Felix You
  • 41
  • 3