[R] approxfun question

peter dalgaard pdalgd at gmail.com
Wed May 21 23:25:25 CEST 2014


On 21 May 2014, at 22:31 , Helio Camargo <heliocamargo at gmail.com> wrote:

> Sorry for the naive question, but is it actually possible do SEE the
> approximation function y=f(x) in any of the output options of approxfun?

Yes and no...

> a <- approxfun(x, y, rule = 2:1)
> a
function (v) 
.approxfun(x, y, v, method, yleft, yright, f)
<bytecode: 0x1159f1118>
<environment: 0x1017ec630>
> ls(environment(a), all=TRUE)
[1] "f"      "method" "x"      "y"      "yleft"  "yright"
> stats:::.approxfun
function (x, y, v, method, yleft, yright, f) 
.Call(C_Approx, x, y, v, method, yleft, yright, f)
<bytecode: 0x1155a91f0>

and if you dig a little deeper, you find that the call to C_approx is also the content of approx() once all the initial "red tape" is peeled off. So the function is really not much different from a call to approx() using the arguments that were saved at the creation of the function.



> 
> Cheers,
> 
> --
> Helio
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list