Skip to contents

Removes one or more tree-ring series (columns) from a data frame of class "rwl". Optionally adds the rownames (assumed to be years) as a column.

Usage

trs_remove(x, series, rownames_to_years = FALSE, trim = FALSE)

Arguments

x

A data.frame of class "rwl", where each column is a tree-ring width series and rownames represent years.

series

A character vector specifying the names of the series (columns) to remove.

rownames_to_years

Logical. If TRUE, the rownames of x (years) are added as a column named year.

trim

Logical. If TRUE, leading and trailing all-NA rows are removed using trs_trim().

Value

A data.frame with the specified series removed. If rownames_to_years = TRUE, the result will have an additional year column.

Examples

rwl <- trs_pseudo_rwl(n_series = 3, series_length = 60, end_date = 2000)
trs_remove(rwl, series = "trs_1")
#>      trs_2 trs_3
#> 1941   115   111
#> 1942   112   109
#> 1943   116   106
#> 1944   117   109
#> 1945   114   109
#> 1946   104    96
#> 1947   109    97
#> 1948   104    96
#> 1949   125   111
#> 1950   114   104
#> 1951   117   110
#> 1952   109   102
#> 1953   101    96
#> 1954    94    95
#> 1955    93    88
#> 1956   101    88
#> 1957   111    98
#> 1958    99    96
#> 1959    93    85
#> 1960   100    97
#> 1961   105   108
#> 1962   101   111
#> 1963    94    97
#> 1964   105   115
#> 1965   108   111
#> 1966   109   116
#> 1967   104   105
#> 1968    89    88
#> 1969    82    78
#> 1970    87    80
#> 1971    83    80
#> 1972    98    81
#> 1973    94    91
#> 1974   104    96
#> 1975   101   109
#> 1976   100   105
#> 1977   101   104
#> 1978   104   111
#> 1979   109   108
#> 1980   105   109
#> 1981    98   101
#> 1982   112   102
#> 1983   116   112
#> 1984   116   105
#> 1985    95    88
#> 1986   106    97
#> 1987    98    98
#> 1988    96    98
#> 1989   117   114
#> 1990   115   115
#> 1991   107   104
#> 1992   103    94
#> 1993   105   104
#> 1994   103   108
#> 1995   104   104
#> 1996   110   105
#> 1997   115   118
#> 1998    98   108
#> 1999   103   113
#> 2000   107   111
trs_remove(rwl, series = c("trs_1", "trs_3"), rownames_to_years = TRUE)
#>      trs_2 year
#> 1941   115 1941
#> 1942   112 1942
#> 1943   116 1943
#> 1944   117 1944
#> 1945   114 1945
#> 1946   104 1946
#> 1947   109 1947
#> 1948   104 1948
#> 1949   125 1949
#> 1950   114 1950
#> 1951   117 1951
#> 1952   109 1952
#> 1953   101 1953
#> 1954    94 1954
#> 1955    93 1955
#> 1956   101 1956
#> 1957   111 1957
#> 1958    99 1958
#> 1959    93 1959
#> 1960   100 1960
#> 1961   105 1961
#> 1962   101 1962
#> 1963    94 1963
#> 1964   105 1964
#> 1965   108 1965
#> 1966   109 1966
#> 1967   104 1967
#> 1968    89 1968
#> 1969    82 1969
#> 1970    87 1970
#> 1971    83 1971
#> 1972    98 1972
#> 1973    94 1973
#> 1974   104 1974
#> 1975   101 1975
#> 1976   100 1976
#> 1977   101 1977
#> 1978   104 1978
#> 1979   109 1979
#> 1980   105 1980
#> 1981    98 1981
#> 1982   112 1982
#> 1983   116 1983
#> 1984   116 1984
#> 1985    95 1985
#> 1986   106 1986
#> 1987    98 1987
#> 1988    96 1988
#> 1989   117 1989
#> 1990   115 1990
#> 1991   107 1991
#> 1992   103 1992
#> 1993   105 1993
#> 1994   103 1994
#> 1995   104 1995
#> 1996   110 1996
#> 1997   115 1997
#> 1998    98 1998
#> 1999   103 1999
#> 2000   107 2000