library(igraph)
#>
#> Attaching package: 'igraph'
#> The following objects are masked from 'package:stats':
#>
#> decompose, spectrum
#> The following object is masked from 'package:base':
#>
#> union
indiv <- 1:10
set.seed(42)
basket <- sample(0:1,40, replace = TRUE)
census1 <-
census2 <- 1
census3 <- 1
census4 <- 1
object <- data.frame(indiv = indiv, census1 = census1, census2 = census2, census3 = census3, census4 = census4)
object[2:5] <- basket
object
#> indiv census1 census2 census3 census4
#> 1 1 0 0 0 1
#> 2 2 0 1 0 1
#> 3 3 0 0 0 1
#> 4 4 0 1 0 1
#> 5 5 1 0 0 0
#> 6 6 1 0 1 1
#> 7 7 1 1 0 0
#> 8 8 1 1 0 1
#> 9 9 0 1 0 1
#> 10 10 1 1 0 1
g <- graph.data.frame(d = object, directed = FALSE)
plot(g, vertex.label = V(g)$name)
