R/grayExamples.R

Defines functions grayExamples

Documented in grayExamples

###############################################################################################
# Function description
#   Examples belonging to both classes
#   A subset of data with examples having identical values for all attributes and value 0 or 1
#   (for the class attribute also called the decision attribute)
# 
#
# Parameters
#   attribute: a matrix or data.frame containing attributes
#   D: the decision vector
#
# Return 
#   1: a list of pairs of identical examples on all atributes
###############################################################################################

grayExamples <- function(attribute, D) {
    df1 <- data.frame(D, attribute)
    
    # compare each values of attributes in every examples 
    for (i in 1:nrow(df1)) {
        # set df3 is null
        df3 <- NULL
        # set num is c()
        num <- c()
        
        # iterate for all attributes   
        for (j in i:nrow(df1)) {  
            if (all(df1[i, -1] == df1[j, -1]) && j != i) {

                #row bind df1 to df3
                df3 <- rbind(df3, df1[j, ])

                #column bind j to num
                num <- cbind(num, j)
                
                # print eery example for which there are another examples (one or more) with the same values of
                # attributes
                
                print(rbind(df1[i, ], df1[j, ]))
            }
        }
    }
    return("end of set")
}

Try the RatingScaleReduction package in your browser

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

RatingScaleReduction documentation built on Jan. 21, 2021, 5:06 p.m.