Description Usage o_set "[<-" See Also
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.
1 | o_set(model, variable, value, i, j)
|
o_setFor changing values of variables in the organism slot of CAB.model objects.
o_set( model, variable, value, i, j )
modelA CAB.model object.
variableThe name of a variable in the organism slot.
valueNew values.
iA numeric vector. Indices for the new values.
jA numeric vector. Defaults to NULL. If not NULL, index becomes the rows for a matrix and col specifies the columns.
Modifies the CAB.model in place.
"[<-"For changing values of variables in the organism slot of CAB.model objects.
"[<-"(x,v,i,j,value)
xA CAB.model object.
vThe name of a variable in the organism slot.
valueNew values.
iOptional. A numeric vector. Indices for the new values. See notes.
jOptional. A numeric vector. See notes.
Modifies the CAB.model in place.
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.
model_do for an example of usage.
set_param for setting all parameters.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.