dimnames | R Documentation |
Get and assign names, row names, column names, and dim names of
"timeSeries"
objects.
"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.
(GNB; todo) The "dim<-"
, currently converts x
to a
vector if value
is NULL
, otherwise it ignores
value
, does nothing and returns x
unchanged. This
behaviour should not be relied upon and may be changed in the future,
e.g. by issuing warning when value
is not NULL
. Or
throwing error altogether if assignment with "dim<-"
is
attempted.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.