"tsp<-"
Martin Maechler
Martin Maechler <maechler@stat.math.ethz.ch>
Wed, 30 Sep 1998 16:40:06 +0200
Thank you, Paul, for reporting this problem:
>>>>> "PaulG" == Paul Gilbert <pgilbert@bank-banque-canada.ca> writes:
PaulG> If value is NULL I think tsp assignment should not return a
PaulG> class ts object. Below is a fixed version.
"tsp<-" <-function(x, value)
{if (is.null(value))
{attr(x, "tsp") <- value
if(inherits(x,"ts")) class(x) <- NULL
return(x)
}
attr(x, "tsp") <- value
class(x) <- "ts"
x
}
Shouldn't we be even more restrictive?
The tsp attribute (hance "value" above) should be
- numeric
- of length 3
And then, I'd rather stop the user than destroy the class of my ts object?!
i.e.
"tsp<-" <- function(x, value)
{
if(!(is.numeric(value) && length(value) == 3))
stop("invalid 'tsp': must be numeric of length 3")
attr(x,"tsp") <- value
x
}
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._