R/indTwo2Three.R

Defines functions indTwo2Three

Documented in indTwo2Three

indTwo2Three <- function(indTwo, n.fac){
    Ad <- matrix(0, ncol=n.fac, nrow=n.fac)
    for(j in 1:ncol(indTwo)){
        Ad[indTwo[1,j],indTwo[2,j]] <- 1
    }
    Ad <- Ad + t(Ad)
    indThree0 <- matrix(triangles(graph_from_adjacency_matrix(Ad)), nrow=3)
    indThree <- apply(indThree0, 2, function(x) x[order(x)])
    if(length(indThree)==0) indThree <- NULL
    return(indThree)
}

Try the FindIt package in your browser

Any scripts or data that you put into this service are public.

FindIt documentation built on Nov. 21, 2019, 1:07 a.m.