Learn R Programming

NetSim (version 0.9)

create_attribute_container: Create an attribute container object and maintain it

Description

Create an attribute container object representing arbitrary values or values from a scale (factor variable) based on a numeric vector, change single values of the container and transform it back into a numeric vector. A scale attribute container has to be chosen for individual dependent variables in stochastic actor-oriented models (SAOMs) for behavior change. A normal attribute container can be chosen to represent independent individual variables in SAOMs.

Usage

create_attribute_container(numericVector) create_scale_attribute_container(numericVector, min = 0, max = 1, by = 1) set_value(attributeContainer, i, value) attribute_container_as_list(attributeContainer) "as.numeric"(x, ...) "as.double"(x, ...) "print"(x, ...)

Arguments

numericVector
A numeric vector
min
Minimum value of the factor variable
max
Maximum value of the factor variable
by
Difference between the factor variables
i
Index of the attribute to be changed. Starts counting from 0, not 1.
value
Set attribute to this value
attributeContainer
A NetSim attribute container object
x
A NetSim attribute container object
...
Potential additional arguments

See Also

create_process_state, create_network

Examples

Run this code
nActors <- 5
numericVector <- c(rep(0, nActors%/%2), rep(1, nActors - nActors%/%2))
attributeContainer1 <- create_attribute_container(numericVector)
attributeContainer2 <- 
	create_scale_attribute_container(numericVector, min = 0, max = 2, by = 1)

attributeContainer1 <- set_value(attributeContainer1, i = 0, value = 5)
# does not change anything as 5 is out of range
attributeContainer2 <- set_value(attributeContainer2, i = 0, value = 5)

as.numeric(attributeContainer1)
as.numeric(attributeContainer2)

Run the code above in your browser using DataLab