Description Usage Arguments Details Value Author(s) See Also Examples

Access and assign (replace) elements from the adjacency matrices or the vertex attributes data frames.

1 2 3 4 5 6 7 8 9 10 11 |

`x` |
A diffnet class object. |

`name` |
String vector. Names of the vertices attributes. |

`as.df` |
Logical scalar. When |

`i` |
Index of the i-th row of the adjacency matrix (see details). |

`j` |
Index of the j-th column of the adjacency matrix (see details) |

`value` |
Value to assign (see details) |

`k` |
Index of the k-th slice of the adjacency matrix (see details). |

`drop` |
Logical scalar. When |

`...` |
Further argumnets to be passed to the method (on development) |

The `[[.diffnet`

methods provides access to the diffnet attributes
data frames, static and dynamic. By providing the `name`

of the corresponding
attribute, depending on whether it is static or dynamic the function will return
either a data frame–static attributes–or a list of these–dynamic attributes.
For the assigning method, `[[<-.diffnet`

, the function will infer what
kind of attribute is by analyzing the dimensions of `value`

, in particular
we have the following possible cases:

Class | Dimension | Inferred |

`matrix` | n*T | Dynamic |

`matrix` | n*1 | Static |

`matrix` | (n*T)*1 | Dynamic |

`data.frame` | n*T | Dynamic |

`data.frame` | n*1 | Static |

`data.frame` | (n*T)*1 | Dynamic |

`vector` | n | Static |

`vector` | n*T | Dynamic |

`list` * | T data.frames/matrices/vectors | Dynamic |

*: With *n * 1* `data.frame`

/`matrix`

or *n* length vector.

Other cases will return with error.

In the case of the slices index `k`

, either an
integer vector with the positions, a character vector with the labels of the
time periods or a logical vector of length `T`

can be used to specify
which slices to retrieve. Likewise, indexing vertices works in the same way
with the only difference that, instead of time period labels and a logical vector
of length `T`

, vertices ids labels and a logical vector of length `n`

should be provided.

When subsetting slices, the function modifies the `toa`

vector as well as the
`adopt`

and `cumadopt`

matrices collapsing network tinmming. For example,
if a network goes from time 1 to 20 and we set `k=3:10`

, all individuals
who adopted prior to time 3 will be set as adopters at time 3, and all individuals
who adopted after time 10 will be set as adopters at time 10, changing the
adoption and cumulative adoption matrices. Importantly, `k`

have no
gaps, and it should be within the graph time period range.

In the case of the assigning methods, a diffnet object. Otherwise,
for `[[.diffnet`

a vector extracted from one of the attributes data frames,
and for `[.diffnet`

a list of length `length(k)`

with the corresponding
`[i,j]`

elements from the adjacency matrix.

George G. Vega Yon

Other diffnet methods: `%*%`

,
`as.array.diffnet`

, `c.diffnet`

,
`diffnet-arithmetic`

,
`diffnet-class`

, `plot.diffnet`

,
`summary.diffnet`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ```
# Creating a random diffusion network ---------------------------------------
set.seed(111)
graph <- rdiffnet(100,5)
# Accessing to a static attribute
graph[["real_threshold"]]
# Accessing to subsets of the adjacency matrix
graph[1,,1:3, drop=TRUE]
graph[,,1:3, drop=TRUE][[1]]
# ... Now, as diffnet objects (the default)
graph[1,,1:3, drop=FALSE]
graph[,,1:3, drop=FALSE]
# Changing values in the adjacency matrix
graph[1, , , drop=TRUE]
graph[1,,] <- -5
graph[1, , , drop=TRUE]
# Adding attributes (dynamic) -----------------------------------------------
# Preparing the data
set.seed(1122)
x <- rdiffnet(30, 5, seed.p.adopt=.15)
# Calculating exposure, and storing it diffe
expoM <- exposure(x)
expoL <- lapply(seq_len(x$meta$nper), function(x) expoM[,x,drop=FALSE])
expoD <- do.call(rbind, expoL)
# Adding data (all these are equivalent)
x[["expoM"]] <- expoM
x[["expoL"]] <- expoL
x[["expoD"]] <- expoD
# Lets compare
identical(x[["expoM"]], x[["expoL"]]) # TRUE
identical(x[["expoM"]], x[["expoD"]]) # TRUE
``` |

srdyal/diffusiontest documentation built on July 31, 2018, 2:14 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.