o_set: Change values in a model

Description Usage o_set "[<-" See Also

Description

In the CAB package, models are implemented in CAB.model child classes. The child classes contain slots that hold functions that are necessary for the model. The model child classes also contain a slot called organisms that contains the necessary parameters. We have two functions for repalcemen, the o_set method, and the "[<-" method. Be aware that "[<-" does not work in the same way as in base R.

Usage

1
o_set(model, variable, value, i, j)

o_set

For changing values of variables in the organism slot of CAB.model objects.

Usage

o_set( model, variable, value, i, j )

Arguments

model

A CAB.model object.

variable

The name of a variable in the organism slot.

value

New values.

i

A numeric vector. Indices for the new values.

j

A numeric vector. Defaults to NULL. If not NULL, index becomes the rows for a matrix and col specifies the columns.

Value

Modifies the CAB.model in place.

"[<-"

For changing values of variables in the organism slot of CAB.model objects.

Usage

"[<-"(x,v,i,j,value)

Arguments

x

A CAB.model object.

v

The name of a variable in the organism slot.

value

New values.

i

Optional. A numeric vector. Indices for the new values. See notes.

j

Optional. A numeric vector. See notes.

Value

Modifies the CAB.model in place.

Notes

If the variable being modified is a matrix, the argument i will change the ith row if j is missing. If i and j are specified, the ijth element of the matrix will be changed. If the variable is a numeric vector, the argument i will change the ith element. Specifying j will return an error. Do not use the syntax x[v,i,j] <- value. For classes in base R, these would be equivalent, but defining custom methods for "[<-" has produced strange results. In using the x[v,i,j] <- value syntax, the assignment will occur at the wrong level and you will destroy your model object. Use the "[<-"(x,v,i,j,value) syntax for desired results. If both i and j are missing, a replacement of the variable in the organism slot is done. If the class of the new object is different from that of the object originally in the variable, then an error is thrown. MORE NOTES: The standard indexing x[i,j,whatever] now works. I have not updated the documentation for it.

See Also

model_do for an example of usage. set_param for setting all parameters.


Don-Li/CAB documentation built on May 6, 2019, 2:52 p.m.

Related to o_set in Don-Li/CAB...