Learn R Programming

gmwm (version 2.0.0)

update.lts: Update Object Attribute

Description

Update the attributes of lts, gts and imu object

Usage

"update"(object, type, new, keep.start = T, ...)
"update"(object, type, new, keep.start = T, ...)
"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.

Value

An object with the updated attribute.

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', 'name' and 'process'. For gts object, the attributes that can be updated are 'start', 'end', 'freq', 'unit' and 'name'. For imu object, the attributes that can be updated are 'axis', 'freq', 'unit' and 'name'.

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' is updated, the old unit will be replaced by the new one, and other attributes will remain the same. It is different from the unit conversion feature.

Examples

Run this code
gts1 = gts(rnorm(50), freq = 1, unit = 'sec', name = 'test1')
gts2 = update(gts1, 'unit', 'min')
attr(gts2, 'unit')

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

Run the code above in your browser using DataLab