checkAssoc <- function(file){
data <- fread(file)
K <- ncol(data)
N <- nrow(data)
out <- as.data.table(matrix(0, nrow=K, ncol=K))
maxGrp <- numeric(1)
cols <- NA
cat("Beginning Correlation Check\n")
print.seq <- seq(1, N, length.out=10)
for(n in 1:N){
if(n %in% print.seq) cat("\r", format(n/N *100, digits=2), "% Complete")
maxGrp <- max(data[n,])
for(k in 1:maxGrp) {
cols <- which(data[n,]==k)
out[cols, cols := cols + 1]
}
}
out <- out/N
diag(out) <- 1
# for(j in 1:K){
# for(i in j:K) out[i,j] <- out[j,i]
# }
return(out)
}
corrY <- function(comp, Q){
corrmat <- as.data.table(matrix(NA, nrow=Q,ncol=Q))
K <- length(comp)
for(k in 1:K){
cols <- comp[[k]]
corrmat[cols,cols := cols + 1]
}
return(corrmat)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.