setCols.DTSg: Set Values of Columns

Description Usage Arguments Value See Also Examples

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

1
2
3
4
5
6
7
8
9
## 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

DTSg, data.table, .N, cols, list, set

Examples

1
2
3
4
5
6
7
8
9
# 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 documentation built on May 30, 2021, 5:06 p.m.