R/field.R

my_function = function(x,y,type = "shared"){
    count = 0
    same = character()
    tryCatch(
        if(class(x) == class(y)){
            for(i in x){
                for (j in y){
                    if(i == j){
                        if(!(is.element(i,same))){
                            same = append(same, i) 
                            count = count + 1}
                        else{print ("class error")}
                    }
                }
            }
        },
        error = function(e) print("error at alleles"), 
        warning = function(w) print("warning at alleles"), finally = NULL)
    if(type == "shared"){
        return(count)
    }else if(type == "different"){
        return(length(x) - count)
    }else{
        return("error at type")
    }            
}
faarseer/systems_biology documentation built on May 20, 2019, 5:20 p.m.