[Rd] example(smooth.spline) fails when function is NOT byte-compiled
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Sep 20 08:58:29 CEST 2012
As the posting guide asked of you, try R-patched or R-devel before
posting, and check the bug repository.
• smooth.spline() used DUP = FALSE which allowed its compiled C
code to change the function: this was masked by the default
byte-compilation. (PR#14965.)
On 19/09/2012 21:41, Hervé Pagès wrote:
> Hi,
>
> example(smooth.spline) fails with the non byte-compiled version of the
> smooth.spline function:
>
> > example(smooth.spline)
>
> smth.s> require(graphics)
>
> smth.s> attach(cars)
>
> smth.s> plot(speed, dist, main = "data(cars) & smoothing splines")
>
> [... more output deleted...]
>
> smth.s> lines(smooth.spline(speed, dist, df=10), lty=2, col = "red")
> Error in smooth.spline(speed, dist, df = 10) :
> smoothing parameter value too small
>
> More precisely, here is what happens on a fresh R session (R-2.15.1
> configured with --disable-byte-compiled-packages):
>
> ** Checking that smooth.spline() is not compiled:
>
> > smooth.spline
> [... output deleted...]
> <environment: namespace:stats>
>
> ** 1st call works:
>
> > res <- smooth.spline(c(4, 4, 7, 7, 8, 9), c(2, 10, 4, 22, 16, 10))
>
>
> ** 2nd call fails:
>
> > res <- smooth.spline(c(4, 4, 7, 7, 8, 9), c(2, 10, 4, 22, 16, 10))
> Error in smooth.spline(c(4, 4, 7, 7, 8, 9), c(2, 10, 4, 22, 16, 10)) :
> smoothing parameter value too small
>
> ** 3rd call (but now with the compiled version of the function) still
> fails:
>
> > library(compiler)
>
> > smooth.spline2 <- cmpfun(smooth.spline)
>
> > smooth.spline2
> [... output deleted...]
> <bytecode: 0x16813a0>
> <environment: namespace:stats>
>
> > res2 <- smooth.spline2(c(4, 4, 7, 7, 8, 9), c(2, 10, 4, 22, 16, 10))
> Error in smooth.spline2(c(4, 4, 7, 7, 8, 9), c(2, 10, 4, 22, 16, 10)) :
> smoothing parameter value too small
>
> Thanks,
> H.
>
> My session info:
>
> > sessionInfo()
> R version 2.15.1 (2012-06-22)
> Platform: x86_64-unknown-linux-gnu (64-bit)
>
> locale:
> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
> [7] LC_PAPER=C LC_NAME=C
> [9] LC_ADDRESS=C LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] compiler stats graphics grDevices utils datasets methods
> [8] base
>
> loaded via a namespace (and not attached):
> [1] tools_2.15.1
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-devel
mailing list