set_dates and get_dates allow to get or set the dates of an object.

get_dates(object)

set_dates(object) <- value

# S4 method for Matrix
get_dates(object)

# S4 method for Matrix
set_dates(object) <- value

Arguments

object

A \(m \times p\) matrix of count data (typically of class Matrix).

value

A possible value for the element(s) of object (see below).

Value

get_dates returns a two-columns data.frame.

Details

An attempt is made to interpret the argument value in a suitable way. Note that errors are assumed to be given at 1 sigma.

If value is a:

character vector

it is assumed to contain Roman numerals.

numeric or integer vector

these values are assumed to represent dates without known errors.

list

containing components "value" and "error", these are used to define dates and corresponding errors.

matrix or data.frame with two or more columns

the first is assumed to contain the dates and the second the error values. Note that if value has columns named "value" and "error", these columns will be used.

Examples

## Create a count data matrix A <- CountMatrix(data = sample(0:10, 100, TRUE), nrow = 10, ncol = 10, dimnames = list(LETTERS[1:10], NULL)) ## Set dates as a matrix B <- matrix(data = sample(0:10, 20, TRUE), nrow = 10, ncol = 2) set_dates(A) <- B get_dates(A)
#> value error #> A 10 0 #> B 5 2 #> C 9 2 #> D 10 9 #> E 8 8 #> F 1 4 #> G 8 7 #> H 8 2 #> I 0 0 #> J 10 10
## Set dates as a data.frame B <- data.frame(sample(0:10, 5, TRUE), sample(0:10, 5, TRUE), row.names = LETTERS[seq(1, 10, 2)]) set_dates(A) <- B get_dates(A)
#> value error #> A 5 5 #> B NA NA #> C 9 9 #> D NA NA #> E 8 3 #> F NA NA #> G 1 8 #> H NA NA #> I 7 2 #> J NA NA
## Set dates as a list B <- list(value = sample(0:10, 10, TRUE), error = sample(0:10, 10, TRUE)) set_dates(A) <- B get_dates(A)
#> value error #> A 6 9 #> B 1 8 #> C 2 10 #> D 10 4 #> E 9 9 #> F 3 4 #> G 5 3 #> H 8 1 #> I 9 1 #> J 1 3
## Set dates as a numeric vector B <- sample(0:10, 10, TRUE) suppressWarnings(set_dates(A) <- B) get_dates(A)
#> value error #> A 1 NA #> B 4 NA #> C 9 NA #> D 3 NA #> E 10 NA #> F 7 NA #> G 1 NA #> H 0 NA #> I 2 NA #> J 7 NA
## Set dates as a character vector B <- c("X", "IX", "VIII", "VII", "VI", "V", "IV", "III", "II", "I") set_dates(A) <- B get_dates(A)
#> value error #> A 10 NA #> B 9 NA #> C 8 NA #> D 7 NA #> E 6 NA #> F 5 NA #> G 4 NA #> H 3 NA #> I 2 NA #> J 1 NA
## Unset dates set_dates(A) <- NULL get_dates(A)
#> [1] value error #> <0 lignes> (ou 'row.names' de longueur nulle)