Learn R Programming

arkhe (version 0.2.2)

chronology: Chronological Information

Description

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

Usage

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

Run this code
# NOT RUN {
## 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)

## 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)

## 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)

## Set dates as a numeric vector
B <- sample(0:10, 10, TRUE)
suppressWarnings(set_dates(A) <- B)
get_dates(A)

## 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)

## Unset dates
set_dates(A) <- NULL
get_dates(A)
# }

Run the code above in your browser using DataLab