jeanimal / heuristica

Heuristic functions in R, such as Take The Best, unit-weighted linear (Dawes' rule), plus helper functions.
Other
5 stars 2 forks source link

Ensure all functions handle NA well #19

Open jeanimal opened 8 years ago

jeanimal commented 8 years ago

Example data: Row 56 of highschool_dropout does not handle NA. Example functions: pairToValue gives the error Error in if (pair[1] > pair[2]) { : missing value where TRUE/FALSE needed And pairToValue is used in predictAlternativeWithCorrect, which is important.

But really all functions should get unit tests for NA input. I am not sure what correct behavior is, and it probably varies by function.

For example, the cueValidity function offers the optional paramter replaceNanWith=0.5.

dnlbrkc commented 8 years ago

I added a private function that allows you to specify how to handles NAs. Every other function could rely on this function.