From: Henrik Bengtsson <hb_at_maths.lth.se>

Date: Wed 05 Apr 2006 - 09:18:21 GMT

R-devel@r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Apr 05 19:44:31 2006

Date: Wed 05 Apr 2006 - 09:18:21 GMT

Hi,

yesterday I got very useful feedback on what is the best way to return a function from a function.

# Simulate data

x <- 1:10

y <- 1:10 + rnorm(length(x))

# Estimate predictor function

fcn <- getPredictor(x,y)

# No extrapolation => no Recall()

ypred <- fcn(x)

print(ypred)

# Gives: # [1] 2.325181 2.756166 ...

To see what's the function looks like, do

pfcn <- getAnywhere("predict.smooth.spline.fit")$obj[[2]] page(pfcn)

A workaround is to set the predict.smooth.spline.fit() in .GlobalEnv, i.e.

predict.smooth.spline.fit <- pfcn

Does Recall() have a problem because predict.smooth.spline.fit() is not exported, or what is going on? Are there alternatives to the above workaround? I can see how such a workaround can become very complicated with complex functions where it is hard to predict what functions are called when.

/Henrik

PS, may I suggest to modify page() so that 'page(getAnywhere("predict.smooth.spline.fit"))' works? DS.

R-devel@r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Apr 05 19:44:31 2006

*
This archive was generated by hypermail 2.1.8
: Wed 05 Apr 2006 - 10:16:49 GMT
*