tind-methods: Basic Methods for 'tind' Class

tind-methodsR Documentation

Basic Methods for tind Class

Description

tind class supports all standard methods for vectors and and vector-based classes like Date or POSIXct.

Usage

## 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, ...)

Arguments

x

an object of tind class.

i

an integer vector of indices or a logical vector indicating selection.

value

replacement value.

...

objects of tind class (for c, min, max, and range) or additional arguments passed to or from methods.

object

an object of tind class.

Details

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.

Value

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").

See Also

format for formatting time indices, Ops for operations on time indices.

Examples

# 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())
)



tind documentation built on Dec. 28, 2025, 1:06 a.m.