You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PLEASE also add a NODELIST (ego, alter1, alter2). Empirical survey data mostly comes as a NODELIST. I have spent so much time with getting nodelists into statnet:
A primitive tidyversian prototype seems straightforward:
txt<-"ego alter1 alter2 alter31 2 3 42 1 33 2 14 1"d<- read.table(textConnection(txt), as.is=TRUE, fill=TRUE, header=TRUE)
d#> ego alter1 alter2 alter3#> 1 1 2 3 4#> 2 2 1 3 NA#> 3 3 2 1 NA#> 4 4 1 NA NA
stopifnot({
library("dplyr")
requireNamespace("tidyr")
})
#> #> Attaching package: 'dplyr'#> The following objects are masked from 'package:stats':#> #> filter, lag#> The following objects are masked from 'package:base':#> #> intersect, setdiff, setequal, union#> Loading required namespace: tidyrd|>tidyr::pivot_longer(-ego, values_to="to") |>
filter(!is.na(to)) |>
select(from=ego, to, nomination=name)
#> # A tibble: 8 × 3#> from to nomination#> <int> <int> <chr> #> 1 1 2 alter1 #> 2 1 3 alter2 #> 3 1 4 alter3 #> 4 2 1 alter1 #> 5 2 3 alter2 #> 6 3 2 alter1 #> 7 3 1 alter2 #> 8 4 1 alter1
... which gives an edgelist ready to be consumed by as.network() data frame method.
The input in the example assumes that adjacency information is "reciprocated"/, i.e. if 1 and 2 are connected then 2 will appear adjacent in the row for 1 and vice versa. Thus each tie unnecessarily appears twice. I believe this corresponds to the adjacency list representation called-upon in some graph algorithms.
On the other hand, in case of "survey data" (presumably a name generator in an egocentric study) ties should be interpreted as directed (thus not reciprocated by design).
PLEASE also add a NODELIST (ego, alter1, alter2). Empirical survey data mostly comes as a NODELIST. I have spent so much time with getting nodelists into statnet:
Originally posted by @jdohmen in #64 (comment)
The text was updated successfully, but these errors were encountered: