fix.data: Fixes input data values, column names and attributes types

View source: R/rmcfs.R

fix.dataR Documentation

Fixes input data values, column names and attributes types

Description

Fixes any input data to prepare them to export to ARFF/ADX formats. If after exporting data to ARFF/ADX formats there are some problems in running Java MCFS or WEKA, try to use this function before. This function fixes data values (e.g. space " " is replaced by "_") and data types (e.g. all Date columns converted to character in R).

Usage

fix.data(x, 
          type = c("all", "names", "values", "types"), 
          source_chars = c(" ", "'", ",", "/", "|", "#", 
                           "-", "(", ")", "[", "]", "{", "}"),
          destination_char = "_", 
          numeric_class = c("difftime"), 
          nominal_class = c("factor", "logical", "Date", "POSIXct", "POSIXt"))

Arguments

x

input data frame to be fixed.

type
  • all - fixes: column names, data values, data types.

  • names - fixes only column names. All characters determined by source_chars parameter are replaced by destination_char (e.g. space " " is replaced by "_").

  • values - fixes only data values. All characters determined by source_chars parameter are replaced by destination_char (e.g. space " " is replaced by "_").

  • types - fixes only data types (e.g. all possible nominal columns as (Date or logical) converted to character).

source_chars

characters that will be replaced in column names and data values.

destination_char

character that will be inserted in column names and data values.

numeric_class

vector of class labels to be casted as.numeric.

nominal_class

vector of class labels to be casted as.character.

Value

data.frame with fixed values and types (depends on type parameter).

Examples

  ## Not run: ###dontrunbegin

  # create artificial data
  adata <- artificial.data(rnd_features = 1000)
  
  # Fix data types and data values - remove "," " " "/" from values and fix data types
  # This function may help if mcfs has any problems with input data
  adata.fixed <- fix.data(adata)
  
  
## End(Not run)###dontrunend

rmcfs documentation built on Sept. 11, 2024, 8:41 p.m.

Related to fix.data in rmcfs...