array2ade4<- function (dataset, pos = FALSE, trans = FALSE) 
   {
    if (!is.data.frame(dataset)) 
        dataset <- getdata(dataset)
    if (any(is.na(dataset))) 
        stop("Arraydata must not contain NA values. Use impute.knn in library(impute), KNNimpute from Troyanskaya et al., 2001 or LSimpute from Bo et al., 2004 to impute missing values\n")
    if (pos) {
        if (any(dataset < 0)) {
            num <- round(min(dataset) - 1)
            dataset <- dataset + abs(num)
        }
    }
    if (trans) {
        colnam= colnames(dataset)
        rownam = rownames(dataset)
        
        dataset <- t(dataset)
        dimnames(dataset) = list(colnam, rownam) 
        dataset <- as.data.frame(dataset)
        print(dataset[1:2,1:2])
         if (!is.data.frame(dataset)) 
            stop("Problems checking dataset")
    }
    data.out <- dataset
    return(data.out)
   }


bga<- function (dataset, classvec, type = "coa", ...) 
    {
    classvec <- checkfac(classvec)
    nclasses = length(levels(classvec))
    data.ord <- ord(dataset, type = type, classvec = classvec, 
        trans = TRUE)
    ord.class = class(data.ord$ord)
    print(data.ord)
    data.bet <- between(data.ord$ord, classvec, scannf = FALSE, 
        nf = nclasses - 1)
    res <- list(ord = data.ord, bet = data.bet, fac = classvec)
    class(res) <- c(type, "bga")
    return(res)
    }
