Learn R Programming

rmcfs (version 1.1.0)

fix.data: 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 bysource.charsparameter are replaced bydestination.char(e.g. space " " is repl
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

Run this code
# Load rmcfs library.
  library(rmcfs)
  
  # Load alizadeh dataset.
  data(alizadeh)

  # 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
  alizadeh.fixed <- fix.data(alizadeh)

Run the code above in your browser using DataLab