Bug 14970 - unexpected behavior in ns(knots=NULL,...)
unexpected behavior in ns(knots=NULL,...)
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Models
R 2.15.0 patched
All All
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-03 01:35 UTC by Randall Pruim
Modified: 2012-07-04 07:32 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Randall Pruim 2012-07-03 01:35:48 UTC
ns(x, df=4, knots=NULL) 

and 

    ns(x, df=4)

produce different results despite the fact that

> args(ns)
function (x, df = NULL, knots = NULL, intercept = FALSE, Boundary.knots = range(x)) 

This is because ns() is testing knots using missing(knots) rather than is.null(knots).  This caused a bug in my code that took some head scratching to locate.  Is this desired behavior or a bug?
Comment 1 Martin Maechler 2012-07-03 16:18:27 UTC
you are right.  This is undesirable... and I'll tackle it
Comment 2 Randall Pruim 2012-07-03 16:21:03 UTC
(In reply to comment #1)
> you are right.  This is undesirable... and I'll tackle it

This affects bs() in the same way and the same fix should work for both.