update.lts: Update Object Attribute

View source: R/update.R

update.ltsR Documentation

Update Object Attribute

Description

Update the attributes of lts, gts and imu object

Usage

## S3 method for class 'lts'
update(object, type, new, keep.start = T, ...)

## S3 method for class 'gts'
update(object, type, new, keep.start = T, ...)

## S3 method for class 'imu'
update(object, type, new, ...)

Arguments

object

A lts, gts or imu object

type

A string that contains the attribute to be updated

new

The updated value for the attribute

keep.start

A boolean value that indicates whether 'start' or 'end' should remain the same when 'freq' is updated

...

Further arguments passed to or from other methods.

Details

This function is able to update some attributes for gts, lts and imu objects. For lts object, the attributes that can be updated are 'start', 'end', 'freq', 'unit_time', 'name_ts' and 'process'. For gts object, the attributes that can be updated are 'start', 'end', 'freq', 'unit_time' and 'name_ts'. For imu object, the attributes that can be updated are 'axis', 'freq', 'unit_time' and 'name_ts'.

If one between 'start' and 'end' is updated, the other one will also be updated, since end-start == (N-1)/freq must be TRUE, where N is the number of observations in the object.

If 'freq' is updated, by default 'start' will remain the same, and 'end' will be updated at the same time, unless you set 'keep.start = F'.

If 'unit_time' is updated, the old unit_time will be replaced by the new one, and other attributes will remain the same. It is different from the unit_time conversion feature.

Value

An object with the updated attribute.

Examples

gts1 = gts(rnorm(50), freq = 1, unit_time = 'sec', name_ts = 'test1')
gts2 = update(gts1, 'unit_time', 'min')
attr(gts2, 'unit_time')

gts3 = update(gts1, 'name_ts', 'test2')
attr(gts3, 'name_ts')

simts documentation built on Aug. 31, 2023, 5:07 p.m.