How to run 'dd<<- datadist (data), options (datadist=' dd ')' correctly in shiny?

I want to use the regplot() function to draw a nomograph. When I run this line of code "dd<<- datadist (data) options (datadist=" dd ")" separately outside of shiny, the nomogram can be displayed normally when I run shiny again.
When I run 'dd<<- datadist (data) options (datadist=' dd ')' in shiny, an error message reads''data 'must be a data.frame', environment, or list”。 When I followed the online feedback and changed the code to "dd<<- datadist (data) options (datadist=dd)", the same error message was reported. I modified the code again, '
dd<- eventReactive (input $update{
data <- data()
dd <<- datadist(data)
options(datadist = "dd")
dd
}
output$regPlot <- renderPlot({
dd()
regplot(fit)
}

This time there was no error, but the image cannot be displayed after running it. I have been struggling with running the regplot() function on shiny recently. Could you please help me solve this problem. thank you!