R/matrixmaker.R

Defines functions matrixmaker

Documented in matrixmaker

matrixmaker <-
function(mat){
k <- ncol(mat)
obs <- nrow(mat)
out <- matrix(NA,obs,((k*(k+1))/2 +1))
count <- 0
 for (i in 1:k){
  for (j in 1:i){
  count <- count + 1
   out[,count] <- mat[,i] * mat[,j]
   colnames(out)[c(count,((k*(k+1))/2 +1))] <-
   c(paste(colnames(mat)[i],".",colnames(mat)[j],sep=""), "dummy")
  }
 }
out <- cbind(mat,out[,1:((k*(k+1))/2)])
out
}

Try the ebal package in your browser

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

ebal documentation built on June 9, 2022, 9:05 a.m.