set.seed(7)
x <- sample(x = rep(1:3, 4), 12)
set.seed(18)
y <- sample(x = rep(1:3, 4), 12)
set.seed(3)
z <- sample(x = rep(1:3, 4), 12)
xyz_comms <- data.frame(id=seq(1:length(x)),x_comm=x,y_comm=y,z_comm=z)
xyz_alleg <- community_allegiance(xyz_comms)
xyz_melt <- reshape2::melt(xyz_alleg)
ggplot2::ggplot(data = xyz_melt) +
ggplot2::theme_minimal() +
ggplot2::aes(x = as.factor(Var1), y = as.factor(Var2), fill = value) +
ggplot2::geom_tile() +
ggplot2::xlab('Node') + ggplot2::ylab('Node') +
ggplot2::ggtitle('Community Allegiance Example') +
ggplot2::scale_fill_gradient2(
low = 'navy',
high = 'goldenrod1',
mid = 'darkturquoise',
midpoint = 0.5,
limit = c(0, 1),
space = 'Lab',
name='')
Run the code above in your browser using DataLab