verbal-autopsy-software / Tariff

R package of Tariff method for VA

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Throw a warning if intersect removes some columns

mjutras-mitre opened this issue · comments

The code works and is harmless in intended case but it would be a good idea to alert the user. If they inadvertently passed in the wrong dataset or something, a warning would catch it.

Tariff/Tariff/R/Tariff.r

Lines 78 to 81 in 2324381

# make sure train and test has the same columns
joint <- intersect(colnames(symps.train), colnames(symps.test))
symps.test <- symps.test[, joint]
symps.train <- symps.train[, joint]

These messages are very useful for the user, but I'm thinking that the if condition might need to be if(length(joint) < length(colnames(symps.train))) and if(length(joint) < length(colnames(symps.test))), respectively? As it stands, I think it's comparing a numeric integer to a vector.