|  | 
| 1 | 1 | #  File src/library/stats/R/ts.R | 
| 2 | 2 | #  Part of the R package, https://www.R-project.org | 
| 3 | 3 | # | 
| 4 |  | -#  Copyright (C) 1995-2024 The R Core Team | 
|  | 4 | +#  Copyright (C) 1995-2025 The R Core Team | 
| 5 | 5 | # | 
| 6 | 6 | #  This program is free software; you can redistribute it and/or modify | 
| 7 | 7 | #  it under the terms of the GNU General Public License as published by | 
| @@ -86,8 +86,10 @@ ts <- function(data = NA, start = 1, end = numeric(), frequency = 1, | 
| 86 | 86 | 		if(ndata < nobs) data[rep_len(1L:ndata, nobs), ] | 
| 87 | 87 | 		else if(ndata > nobs) data[1L:nobs, ] | 
| 88 | 88 | 	    } | 
| 89 |  | -    ## FIXME: The following "attr<-"() calls C tspgets() which uses a | 
| 90 |  | -    ##  	fixed equivalent of ts.eps := 1e-5 | 
|  | 89 | +    ## attr(data, "tsp") <- .. below calls C tspgets() which uses getOption("ts.eps"): | 
|  | 90 | +    if(doEps <- !missing(ts.eps) && ts.eps != getOption("ts.eps")) { | 
|  | 91 | +        op <- options(ts.eps = ts.eps); on.exit(options(op)) | 
|  | 92 | +    } | 
| 91 | 93 |     attr(data, "tsp") <- c(start, end, frequency) #-- order is fixed | 
| 92 | 94 |     if(!is.null(class) && class[[1]] != "none") attr(data, "class") <- class | 
| 93 | 95 |     ## if you alter the return structure, you also need to alter | 
| @@ -400,7 +402,7 @@ print.ts <- function(x, calendar, ...) | 
| 400 | 402 |     invisible(x) | 
| 401 | 403 | } | 
| 402 | 404 | 
 | 
| 403 |  | -## To be used in a  format.ts(): | 
|  | 405 | +## used in print.ts(), and to be used in a (future / other pkg) format.ts() | 
| 404 | 406 | .preformat.ts <- function(x, calendar, ...) | 
| 405 | 407 | { | 
| 406 | 408 |     fr.x <- frequency(x) | 
| @@ -456,7 +458,7 @@ print.ts <- function(x, calendar, ...) | 
| 456 | 458 | 		    paste(month.abb[t2], p1) | 
| 457 | 459 | 		else | 
| 458 | 460 | 		    paste(p1, if(fr.x == 4) c("Q1", "Q2", "Q3", "Q4")[t2] | 
| 459 |  | -			  else format(t2)) | 
|  | 461 | +			      else format(t2)) | 
| 460 | 462 | 	    } else | 
| 461 | 463 | 		format(time(x)) | 
| 462 | 464 |         attr(x, "class") <- attr(x, "tsp") <- attr(x, "na.action") <- NULL | 
|  | 
0 commit comments