Brian R makes good points. I made a mistake in the prior post, it should have said new.env(parent=globalenv()) for pspline. You want the saved function to pay attention to the search() path. This is what is actually in the code, I was guilty of mistyping. If the print function uses a not-exported function from the enclosing package then we need to be more careful. This is the case for rpart.
Large file size while persisting rpart model to disk
1 message · Terry Therneau