| NetIndClass {simcausal} | R Documentation |
R6 class for creating and storing a friend matrix (network IDs) for network data
Description
This R6 class defines fields and methods for creating and storing NetInd_k,
a matrix of friend indices (network IDs) of dim = (nobs x Kmax).
Format
An R6Class generator object
Details
NetInd - Matrix of friend indices (network IDs) of
dim = (nobs x Kmax)(Active Binding).nF - Vector of integers, where
nF[i]is the integer number of friends (0 toKmax) for observationi.nobs - Number of observations
Kmax - Maximum number of friends for any observation.
Methods
new(nobs, Kmax = 1)Uses
nobsandKmaxto instantiate an object of R6 class and pre-allocate memory for the future network ID matrix.makeNetInd.fromIDs(Net_str, IDs_str = NULL, sep = ' ')Build the matrix of network IDs (
NetInd_k) from IDs string vector, all friends of one observationiare located in a string Net_str[i], with two distinct friend IDs ofiseparated by charactersep. IfIDs_stris NULL it is assumed that the friends in Net_str are actual row numbers in1:nobs, otherwise IDs from Net_str will be used for looking up the observation row numbers inIDs_str.make.nF(NetInd_k = self$NetInd_k, nobs = self$nobs, Kmax = self$Kmax)This method calculates the integer number of friends for each row of the network ID matrix (
self$NetInd_k). The result is assigned to a fieldself$nFand is returned invisibly.mat.nF(nFnode)nFnode- the character name for the number of friends variable that is assigned as a column name to a single column matrix inself$nF.
Methods
Public methods
Method new()
Usage
NetIndClass$new(nobs, Kmax = 1)
Method makeNetInd.fromIDs()
Usage
NetIndClass$makeNetInd.fromIDs(Net_str, IDs_str = NULL, sep = " ")
Method make.nF()
Usage
NetIndClass$make.nF( NetInd_k = self$NetInd_k, nobs = self$nobs, Kmax = self$Kmax )
Method mat.nF()
Usage
NetIndClass$mat.nF(nFnode)
Method clone()
The objects of this class are cloneable with this method.
Usage
NetIndClass$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.