Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

setCols.DTSg

Set Values of Columns


Description

Set the values of columns, add columns to and/or remove columns from a DTSg object. The values can optionally be set for certain rows only.

Usage

## S3 method for class 'DTSg'
setCols(
  x,
  i,
  cols = self$cols(class = "numeric")[1L],
  values,
  clone = getOption("DTSgClone"),
  ...
)

Arguments

x

A DTSg object (S3 method only).

i

An integerish vector indexing rows (positive numbers pick and negative numbers omit rows) or a filter expression accepted by the i argument of data.table. Filter expressions can contain the special symbol .N.

cols

A character vector specifying the columns whose values shall be set. The values of the .dateTime column cannot be set.

values

A vector, list or list-like object (e.g. data.table) of replacement and/or new values accepted by the value argument of data.table's set function. NULL as a value removes a column.

clone

A logical specifying if the object is modified in place or if a clone (copy) is made beforehand.

...

Not used (S3 method only).

Value

Returns a DTSg object.

See Also

Examples

# new DTSg object
x <- DTSg$new(values = flow)

# cap river flows to 100
## R6 method
x$setCols(i = flow > 100, cols = "flow", values = 100)

## S3 method
setCols(x = x, i = flow > 100, cols = "flow", values = 100)

DTSg

A Class for Working with Time Series Based on 'data.table' and 'R6' with Largely Optional Reference Semantics

v0.7.0
MIT + file LICENSE
Authors
Gerold Hepp [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.