uts_matrix_long: Create uts_matrix from long tabular data

Description Usage Arguments Value See Also Examples

View source: R/wide_long.R

Description

Create a "uts_matrix" from long (also known as narrow) tabular data. Data in this format has four different columns; the observation values, the observation times, the entity name of each observation (e.g. person, country), and the attribute/field name of each observation (e.g. which one of serveral economic indicators, which one of several blood measurement values).

Usage

1
uts_matrix_long(values, times, names = base::names(values), fields)

Arguments

values

a vector observation values.

times

a POSIXct object. The matching observation times.

names

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

fields

a character vector. The the matching attribute/field names for the observations.

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 distinct attribute/field names (parameter fields).

See Also

uts_matrix_wide, uts_vector_long, uts_vector_wide

Examples

1
2
3
4
5
6
7
values <- c(A=1, A=2, B=3, B=4, A=5)
times <- as.POSIXct("2016-01-01") + dhours(1:5)
uts_matrix_long(values, times, fields=c("c", "d", "d", "d", "d"))


uts_matrix_long(values=1:5, times=as.POSIXct("2015-01-01") + days(1:5),
  names=c("A", "A", "B", "B", "A"), fields=c("c", "d", "d", "d", "d"))

andreas50/utsMultivariate documentation built on Sept. 27, 2021, 10:33 p.m.