uts_matrix_wide: Create uts_matrix from wide tabular data

Description Usage Arguments Value See Also Examples

Description

Create a "uts_matrix" from wide tabular data (see Wikipedia). For data in this format, each row is a vector of observations (also known as a record) for a specific entity (e.g. person, country) at a specific time point. The record consists of measurements across multiple attributes/fields (e.g. several economic indicators, several blood measurement values).

Usage

1
2
uts_matrix_wide(values, times, names = base::rownames(values),
  fields = base::colnames(values))

Arguments

values

a matrix or data.frame of observation values.

times

a POSIXct object. The matching observation times for the records (i.e. rows of values).

names

a character vector. The the matching entity names for the records. By default, the row names of values are used.

fields

a character vector. The the attribute/field names of the records. By default, the column names of values are used.

Value

An object of class "uts_matrix". The time series in row entity_name and column field_name contains all observations of such entity for such field.

The number of rows is given by to the number of distinct entity names (parameter names), while the number of columns is given by the number of attributes/fields, i.e. the number of columns of values.

See Also

uts_matrix_long, uts_vector_long, uts_vector_wide

Examples

1
2
3
4
5
6
7
8
values <- matrix(1:8, 4, 2)
rownames(values) <- c("CH", "CH", "FR", "US")
colnames(values) <- c("population", "size")
times <- as.POSIXct("2016-01-01") + days(1:4)
uts_matrix_wide(values, times)

# Same, but manually provide entity names
uts_matrix_wide(values, times, names=c("China", "China", "France", "USA"))

andreas50/utsMultivariate documentation built on May 12, 2019, 10:31 p.m.