Skip to content

Commit 56c43b7

Browse files
committed
cleaning the chunks of kfam
1 parent 0d8cdea commit 56c43b7

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

2-read.qmd

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: "Reading Data"
33
author:
44
- Thomas W. Valente
55
- George G. Vega Yon
6+
- Aníbal Olivera M.
67
date: "2025-06-24"
78
date-modified: "2025-06-24"
89
---
@@ -72,10 +73,12 @@ Let's have a look to `kfamily`:
7273
#| message: false
7374
7475
data(kfamily)
76+
77+
# The data contains adoption information of 25 villages:
7578
unique(kfamily$village)
7679
77-
# toa = 11 means 'no adoption'
78-
hist(kfamily$toa)
80+
# across 10 time steps (toa = 11 means 'no adoption')
81+
sort(unique(kfamily$toa))
7982
```
8083

8184
We can construct a `diffnet` object from from those survey data:
@@ -134,7 +137,7 @@ se <- exposure(kfamily_diffnet,
134137
head(round(se, 2))
135138
```
136139

137-
Finally...
140+
The `diffnet` object also contains attributes of the vertices, which can be retrieved using `diffnet.attrs()`:
138141

139142
```{r}
140143
#| label: kfamily-diffnet-attrs
@@ -143,7 +146,12 @@ Finally...
143146
144147
# Retrieving attributes as data.frame
145148
kfamily_diffnet.df <- diffnet.attrs(kfamily_diffnet, as.df = TRUE)
146-
ncol(kfamily_diffnet.df)
149+
150+
# Subset to relevant variables
151+
kfamily_relevant_vars <- kfamily_diffnet.df[, c("per", "toa", "village")]
152+
153+
# Select 10 random rows
154+
kfamily_relevant_vars[sample(nrow(kfamily_relevant_vars), 10), ]
147155
```
148156

149157

files/intro.rda

3 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)