rmaia / pavo

tools for the analysis of color data in R
http://pavo.colrverse.com
GNU General Public License v2.0
68 stars 17 forks source link

`colcat()` returns NULL when x or y is 0 #244

Closed Bisaloo closed 1 year ago

Bisaloo commented 1 year ago

https://github.com/rmaia/pavo/blob/a7f8a4f71547e1c185ba235fa5e256eef17c9e6a/R/categorical.R#L106-L119

This causes issues downstream in colspace() / categorical() because vapply() expected a non-NULL character:

https://github.com/rmaia/pavo/blob/a7f8a4f71547e1c185ba235fa5e256eef17c9e6a/R/categorical.R#L123

A fix could be to return only "y+" / "y-" based on the value of y when x is 0. In this scenario, if both x and y are 0, the output of colcat() would be "".

Bisaloo commented 1 year ago

Alternatively:

thomased commented 1 year ago

Ah, okay — nice catch, thanks!

I'm leaning toward your first idea. So it'd only use y if x is 0, or vice-versa. Then if both x and y are 0 it'd give NA. (Is there a practical reason to prefer "" over NA?).

I'll sketch in the fix shortly.

thomased commented 1 year ago

Popped in here - 813622edf1d94b4bc1f600d55388876b86ec22c2