swh:1:snp:a4c99a50dc49f82b591f268001b320f8c3ca0041
Raw File
Tip revision: dc000f2a5f006d137f66716b086025d618bf8306 authored by John M Chambers on 14 July 2008, 00:00:00 UTC
version 1.0-5
Tip revision: dc000f2
trackClass.R
setClass("track", representation(x ="numeric", y="numeric"))
setClass("track3", representation(z="numeric"), contains = "track")
setMethod("plot",
    signature("track", "missing"),
    function (x, y, ...) 
    {
        plot(x@x, x@y, asp = 1, ...)
    }
)
setMethod("plot", c("track3", "missing"), #version 2
          function(x, y, points = c(".", "o", "*"), ...) {
              which = as.integer(cut(x@z, length(points)))
              callNextMethod(x, pch = points[which], ...)
              })

## some example data
xy <- scan("Examples/gps1XY.txt", list(y = numeric(), x=numeric()))
tr = new("track", x=xy$x, y = xy$y)
t3 = new("track3", x = xy$x, y = xy$y, z=1:length(xy$x))
t3@x[1:10] = jitter(t3@x[1:10]) # to make comparisons interesting
back to top