Skip to contents

Sets the row names (years) of an rwl-style data frame based on a specified end year. Optionally trims trailing rows with only NA values.

Usage

trs_end_date(x, end_year = 2025, trim = FALSE)

Arguments

x

A data.frame of class "rwl", with each column representing a tree-ring series.

end_year

An integer. The calendar year assigned to the most recent tree ring (last row).

trim

Logical. If TRUE, the data frame is trimmed to remove leading and trailing rows with no data (see trs_trim).

Value

A data.frame with row names set to calendar years.

Examples

rwl <- trs_pseudo_rwl(n_series = 2, series_length = 50)
trs_end_date(rwl, end_year = 2000)
#> End date set for all series in x
#>      trs_1 trs_2
#> 1951    95    91
#> 1952    98   106
#> 1953    96   103
#> 1954    96    92
#> 1955    95    98
#> 1956    89    96
#> 1957    89    98
#> 1958   113   111
#> 1959   115   106
#> 1960   107    90
#> 1961   106   100
#> 1962   122   104
#> 1963   134   118
#> 1964   131   114
#> 1965   136   117
#> 1966   127   121
#> 1967   116   116
#> 1968   109   106
#> 1969   118   108
#> 1970   111   103
#> 1971   106    95
#> 1972   110    89
#> 1973   104    92
#> 1974   111    96
#> 1975   107    98
#> 1976   101    90
#> 1977    94    87
#> 1978    98    85
#> 1979    83    83
#> 1980    86    87
#> 1981    92    97
#> 1982    92   106
#> 1983    85   112
#> 1984    95   105
#> 1985   105   120
#> 1986   107   118
#> 1987   115   123
#> 1988   115   122
#> 1989   105   110
#> 1990   107   112
#> 1991    97    99
#> 1992   110   115
#> 1993   104   109
#> 1994   108   108
#> 1995    96   104
#> 1996    93    97
#> 1997   103   105
#> 1998   107   107
#> 1999   101   101
#> 2000   103   100
trs_end_date(rwl, end_year = 2000, trim = TRUE)
#> End date set for all series in x
#>      trs_1 trs_2
#> 1951    95    91
#> 1952    98   106
#> 1953    96   103
#> 1954    96    92
#> 1955    95    98
#> 1956    89    96
#> 1957    89    98
#> 1958   113   111
#> 1959   115   106
#> 1960   107    90
#> 1961   106   100
#> 1962   122   104
#> 1963   134   118
#> 1964   131   114
#> 1965   136   117
#> 1966   127   121
#> 1967   116   116
#> 1968   109   106
#> 1969   118   108
#> 1970   111   103
#> 1971   106    95
#> 1972   110    89
#> 1973   104    92
#> 1974   111    96
#> 1975   107    98
#> 1976   101    90
#> 1977    94    87
#> 1978    98    85
#> 1979    83    83
#> 1980    86    87
#> 1981    92    97
#> 1982    92   106
#> 1983    85   112
#> 1984    95   105
#> 1985   105   120
#> 1986   107   118
#> 1987   115   123
#> 1988   115   122
#> 1989   105   110
#> 1990   107   112
#> 1991    97    99
#> 1992   110   115
#> 1993   104   109
#> 1994   108   108
#> 1995    96   104
#> 1996    93    97
#> 1997   103   105
#> 1998   107   107
#> 1999   101   101
#> 2000   103   100