File: s.q

package info (click to toggle)
r-cran-vgam 0.8-7-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 6,580 kB
  • sloc: ansic: 6,103; fortran: 3,885; makefile: 3
file content (40 lines) | stat: -rw-r--r-- 787 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# These functions are
# Copyright (C) 1998-2012 T.W. Yee, University of Auckland.
# All rights reserved.




s <- function(x, df = 4, spar = 0, ...) {

  xs <- substitute(x)
  ans <- as.character(xs)
  if (length(ans) > 1)
    stop("x argument must be of length one")

  call <- deparse(sys.call())

  if (ncol(as.matrix(x)) > 1)
    stop("x must be a vector") 
  if (!is.null(levels(x))) {
    x <- if (is.ordered(x)) {
      as.vector(x)
    } else
      stop("unordered factors cannot be used as smoothing variables")
  }
  attr(x, "spar") <- spar
  attr(x, "df") <- df
  attr(x, "call") <- call
  attr(x, "class") <- "smooth"
  attr(x, "s.xargument") <- ans   # Needed for prediction and constraints
 

  a <- is.na(x)
  if (any(a))
    attr(x, "NAs") <- seq(along = x)[a]

  x
}