Learn R Programming

timeSeries (version 4041.111)

dimnames: Dimension and their names for 'timeSeries' objects

Description

Get and assign names, row names, column names, and dim names of "timeSeries" objects.

Arguments

Details

"timeSeries" methods are available for base R functions working on dimension names, including dim, dimnames, colnames, rownames, names and their assignment variants.

dim is the dimension of the underlying data matrix.

rownames gives the datetime stamps as a character vector. rownames<- sets them.

colnames gives the values of x@units. These are conceptually the column names of the data matrix. colnames<- sets slot units of x.

dimnames gives list(rownames(x), colnames(x). dimnames<- calls rownames and colnames on value[[1]] and value[[2]], respectively.

Examples

Run this code
## Load Swiss Pension Fund Benchmark Data -
   X <- LPP2005REC[1:10, 1:3]
   
## Get Dimension - 
   dim(X)
   
## Get Column and Row Names -
   dimnames(X)
   
## Get Column / Row Names -
   colnames(X)
   rownames(X) 
   
## Try your own DIM - 
   DIM <- function(x) {c(NROW(x), NCOL(x))}
   DIM(X) 
   DIM(X[, 1])

## Try length / LENGTH - 
   length(X)
   length(X[, 1])
   LENGTH <- function(X) NROW(X)
   LENGTH(X)
   
## Columns / Rows - 
   ncol(X); NCOL(X)
   nrow(X); NROW(X)
                
## See also - 
   isUnivariate(X)
   isMultivariate(X)

Run the code above in your browser using DataLab