Skip to content

Commit

Permalink
converts factors with levels T,F to logical, RWeka does this
Browse files Browse the repository at this point in the history
  • Loading branch information
berndbischl committed Aug 26, 2015
1 parent ea387ec commit 8e4ed73
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion R/readARFF.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ readARFF = function(path, data.reader = "readr", tmp.file = tempfile(), show.inf
ct = header$col.types[i]
if (ct == "factor") {
clevs = header$col.levels[[i]]
dat[,i] = factor(dat[,i], levels = clevs)
# RWEKA parses this to logical
# FIXME: DOC THIS!
if (identical(clevs, c("TRUE", "FALSE")) || identical(clevs, c("FALSE", "TRUE")))
dat[,i] = as.logical(dat[,i])
else
dat[,i] = factor(dat[,i], levels = clevs)
}
}
})
Expand Down

0 comments on commit 8e4ed73

Please sign in to comment.