Learn R Programming

RoughSets (version 1.0-0)

SF.read.DecisionTable: The importing function

Description

It is a additional function used to import dataset from files and then construct them into the standard decision table.

Usage

SF.read.DecisionTable(filename, decision.attr = NULL,
    indx.nominal = NULL, ...)

Arguments

filename
a file name that contains objects/data.
decision.attr
a index position of decision attribute. When we ignore this parameter, the function will treat the data as an information system or newdata/testing data. In other words, we must define the index of decision attribute if we have the decision attr
indx.nominal
a indexes of nominal values. It is used to define specific indexes as nominal attributes.
...
other parameters which are involved in read.table function. See read.table.

Value

Details

It is used to read a dataset from files with the following format: ".csv", ".txt", ".dat", and ".xls", into decision table format. The data should be in table format containing rows and columns without header, where every row represents every object/instance while columns represent attributes of the objects.

The output of this function is a decision table which fulfills a standard format of RoughSets package (See SF.asDecisionTable). In order to construct the decision table, especially in determining description of attributes, this function uses simple heuristic techniques as follows:

  • string values: they will be recognized as nominal/symbolic values.
  • integer values: they will be recognized as continuous/real values.
  • decimal/real values: they will be recognized as continuous/real values.
  • indx.nominal: the attributes that are set in this parameter will be assigned as nominal values.

Examples

Run this code
#############################################################
## Example 1: dataset saved in a file
#############################################################
## Let us assume we have the following data which has been already saved to the file "tes.dat"
data <- data.frame(c(0.12, 0.23, 0.24), c(1,3,2), c(10, 12, 18), c("a", "a", "b"), c(1, 1, 2))
write.table(data, file = "tes.dat", row.names = FALSE, col.names = FALSE,
                    fileEncoding ="")

## Then we would generate decision table from tes.dat file.
## in this case, we want to define that second and third attributes are nominal and continuous,
## respectively.
decision.table <- SF.read.DecisionTable(filename = "tes.dat", decision.attr = 4,
                  indx.nominal = 2, sep= " ", col.names = c("v1", "v2", "v3", "v4", "o1"))

Run the code above in your browser using DataLab