| tind-methods | R Documentation |
tind Classtind class supports all standard methods for vectors and
and vector-based classes like Date or POSIXct.
## S3 method for class 'tind'
x[i]
## S3 replacement method for class 'tind'
x[i] <- value
## S3 method for class 'tind'
x[[i]]
## S3 replacement method for class 'tind'
x[[i]] <- value
## S3 replacement method for class 'tind'
length(x) <- value
## S3 method for class 'tind'
rep(x, ...)
## S3 method for class 'tind'
c(...)
## S3 method for class 'tind'
unique(x, ...)
## S3 method for class 'tind'
print(x, ...)
## S3 method for class 'tind'
summary(object, ...)
x |
an object of |
i |
an integer vector of indices or a logical vector indicating selection. |
value |
replacement value. |
... |
objects of |
object |
an object of |
tind class supports standard indexing via [] and [[]]
operators, as well as replacement, In replacement, it is expected that the
right hand side is of the same type as the indexed object.
length, length<-, and rep methods work in a standard way.
rev, head, tail, as they are implemented using []
operator, are also available for objects of tind class.
Concatenation method (c) works in a standard way. It is expected that
all arguments are of the same type. Arguments that are not of tind class
are converted.
min, max, and range work in a standard way. If the results
are not proper time indices (for example maximum over a vector of length 0),
NAs are returned.
unique, duplicated, order, sort, etc.
work in a standard way.
print prints time indices on the console and invisibly returns its
argument.
summary method returns summary information about time indices.
In general, methods return objects of tind class.
print returns its argument invisibly and is used for its side effect.
summary returns an object of class c("summaryDefault", "table").
format for formatting time indices,
Ops for operations on time indices.
# test sample
(dd <- as.tind(20210131) + sample((0:9), 15, replace = TRUE))
# indexing
dd[1]
dd[[1]]
dd[[1]] <- dd[[1]] + 1
dd
dd[2:3] <- dd[2:3] + 1
dd
# this will generate an error
try(
dd[10] <- now()
)
# length, length<-
length(dd)
length(dd) <- 7
dd
# rep, head, tail, rev
rep(dd, 2)
head(dd, 3)
tail(dd, -5)
rev(dd)
# min, max, range
min(dd)
max(dd)
range(dd)
# unique, duplicated
unique(dd)
duplicated(dd)
# order, sort
order(dd)
sort(dd)
# concatenation
c(dd, rev(dd))
# attempt at concatenating different types will result in an error
try(
c(today(), now())
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.