From 1afa77dfa1f4f548390308cae07b3216521f5fbe Mon Sep 17 00:00:00 2001
From: "Pavel N. Krivitsky"
Date: Sun, 29 Sep 2024 19:27:46 +1000
Subject: [PATCH] Added examples of directly specifying values in levels2=.
references statnet/ergm#563
---
R/get.node.attr.R | 6 ++++++
man/nodal_attributes.Rd | 6 ++++++
vignettes/nodal_attributes.Rmd | 6 ++++++
3 files changed, 18 insertions(+)
diff --git a/R/get.node.attr.R b/R/get.node.attr.R
index 1222e053a..5418e2abc 100644
--- a/R/get.node.attr.R
+++ b/R/get.node.attr.R
@@ -231,6 +231,12 @@ get.node.attr <- function(nw, attrname, functionname=NULL, numeric=FALSE) {
#' # Select via an index of a cell:
#' idx <- cbind(1,2)
#' summary(faux.mesa.high~mm("Sex", levels2=idx))
+#' # Or, select by specific attribute value combinations, though note
+#' # the names 'row' and 'col' and the order for undirected networks:
+#' summary(faux.mesa.high~mm("Sex",
+#' levels2 = I(list(list(row="M",col="M"),
+#' list(row="M",col="F"),
+#' list(row="F",col="M")))))
#'
#' # mm() term allows two-sided attribute formulas with different attributes:
#' summary(faux.mesa.high~mm(Grade~Race, levels2=TRUE))
diff --git a/man/nodal_attributes.Rd b/man/nodal_attributes.Rd
index 8f55ee46c..9c7135f57 100644
--- a/man/nodal_attributes.Rd
+++ b/man/nodal_attributes.Rd
@@ -195,6 +195,12 @@ summary(faux.mesa.high~mm("Sex", levels2=M)+mm("Sex", levels2=t(M)))
# Select via an index of a cell:
idx <- cbind(1,2)
summary(faux.mesa.high~mm("Sex", levels2=idx))
+# Or, select by specific attribute value combinations, though note
+# the names 'row' and 'col' and the order for undirected networks:
+summary(faux.mesa.high~mm("Sex",
+ levels2 = I(list(list(row="M",col="M"),
+ list(row="M",col="F"),
+ list(row="F",col="M")))))
# mm() term allows two-sided attribute formulas with different attributes:
summary(faux.mesa.high~mm(Grade~Race, levels2=TRUE))
diff --git a/vignettes/nodal_attributes.Rmd b/vignettes/nodal_attributes.Rmd
index 06a1a3908..59cb02f08 100644
--- a/vignettes/nodal_attributes.Rmd
+++ b/vignettes/nodal_attributes.Rmd
@@ -192,6 +192,12 @@ summary(faux.mesa.high~mm("Sex", levels2=M)+mm("Sex", levels2=t(M)))
# Select via an index of a cell:
idx <- cbind(1,2)
summary(faux.mesa.high~mm("Sex", levels2=idx))
+# Or, select by specific attribute value combinations, though note the
+# names 'row' and 'col' and the order for undirected networks:
+summary(faux.mesa.high~mm("Sex",
+ levels2 = I(list(list(row="M",col="M"),
+ list(row="M",col="F"),
+ list(row="F",col="M")))))
```
The attributes of the `mm()` term can be a two-sided formula with different attributes: