~ubuntu-branches/ubuntu/trusty/r-cran-vgam/trusty

« back to all changes in this revision

Viewing changes to R/s.q

  • Committer: Package Import Robot
  • Author(s): Chris Lawrence
  • Date: 2011-11-04 13:13:06 UTC
  • mfrom: (1.2.9)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: package-import@ubuntu.com-20111104131306-w9fd83i51rw60gxf
Tags: upstream-0.8-4
ImportĀ upstreamĀ versionĀ 0.8-4

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
 
7
7
 
8
 
s <- function(x, df=4, spar=0, ...)
9
 
{
10
 
 
11
 
    xs <- substitute(x)
12
 
    ans <- as.character(xs)
13
 
    if (length(ans) > 1)
14
 
        stop("x argument must be of length one")
15
 
 
16
 
    call <- deparse(sys.call())
17
 
 
18
 
    if (ncol(as.matrix(x)) > 1)
19
 
        stop("x must be a vector") 
20
 
    if (!is.null(levels(x))) {
21
 
        x <- if (inherits(x, "ordered")) codes(x) else
22
 
            stop("unordered factors cannot be used as smoothing variables")
23
 
    }
24
 
    attr(x, "spar") <- spar
25
 
    attr(x, "df") <- df
26
 
    attr(x, "call") <- call
27
 
    attr(x, "class") <- "smooth"
28
 
    attr(x, "s.xargument") <- ans   # Needed for prediction and constraints
 
8
s <- function(x, df = 4, spar = 0, ...) {
 
9
 
 
10
  xs <- substitute(x)
 
11
  ans <- as.character(xs)
 
12
  if (length(ans) > 1)
 
13
    stop("x argument must be of length one")
 
14
 
 
15
  call <- deparse(sys.call())
 
16
 
 
17
  if (ncol(as.matrix(x)) > 1)
 
18
    stop("x must be a vector") 
 
19
  if (!is.null(levels(x))) {
 
20
    x <- if (is.ordered(x)) {
 
21
      as.vector(x)
 
22
    } else
 
23
      stop("unordered factors cannot be used as smoothing variables")
 
24
  }
 
25
  attr(x, "spar") <- spar
 
26
  attr(x, "df") <- df
 
27
  attr(x, "call") <- call
 
28
  attr(x, "class") <- "smooth"
 
29
  attr(x, "s.xargument") <- ans   # Needed for prediction and constraints
29
30
 
30
31
 
31
 
    a <- is.na(x)
32
 
    if (any(a))
33
 
        attr(x, "NAs") <- seq(along = x)[a]
 
32
  a <- is.na(x)
 
33
  if (any(a))
 
34
    attr(x, "NAs") <- seq(along = x)[a]
34
35
 
35
 
    x
 
36
  x
36
37
}
37
38
 
38
39