Skip to content

Small bugs with the C++ implementation #23

@pierreroudier

Description

@pierreroudier

There seem to have a few remaining issues related to the C++ part of the package, that was kindly contributed by @kdaust (see #15).

Technically, it seems the problem is actually not as much in the C++ code itself, but in the R code that precedes it.

First, this for loop (now commented out):

clhs/R/clhs-data.frame.R

Lines 79 to 82 in 8d45408

# for(i in 1:ncol(data_factor)){
# data_factor[,i] <- as.numeric(as.factor(data_factor[,i]))
# }
data_factor <- apply(data_factor, 2, function(x) as.numeric(as.factor(x)))

This converts automatically any character data to NAs.
I think it can be fixed by using as.numeric(as.factor(data_factor[,i)). I've implemented a version of this using apply.

Second issue, probably minor, but this line here looks like it's a hardcoded "5":

clhs/R/clhs-data.frame.R

Lines 89 to 92 in 8d45408

data <- as.matrix(x)
factIdx <- 1:5 # why five??
ncont <- ncol(data)
data_continuous <- x

I'm guessing it should be a 0?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions