RTIInternational/rollmatch

trimPool function inconsistencies

idest88 opened this issue · 2 comments

I am getting errors from the rollmatch() function that originate in what seem to be coding errors in the rollmatch() and trimPool() functions.

First, the trimPool() function automatically applies a caliper of 0.2, ignoring the caliper argument in the outer rollmatch() function, I think the function call should be trimmed_pool <- trimPool(caliper, ...), rather than trimmed_pool <- trimPool(0.2, ...).

Second, within the trimPool() function I am getting an error because the width argument, a 1x1 matrix, is not of the same dimensions as the data set, data_pool. I think you could resolve this issue by changing the line of code from dplyr::filter(data_pool, data_pool$difference <= width) to dplyr::filter(data_pool, difference <= as.numeric(width)).

rchew commented

Hi idest88,

Thanks for catching this and for using rollmatch!

The first issue of the ignored caliper/alpha argument is fixed with commit e35b55f. However, I'm having trouble recreating the second issue -- in the versions of the code I've checked, the width variable within trimPool is already numeric before entering the filter function. To be safe, I took your suggestion and forced width to numeric with as.numeric(width) (5941422).

Going to close this, but let me know if you're still having issues.

Thanks! I later figured out that the issue with the caliper width being a matrix arose because my input data was a tibble, not a data.frame as the function expected. Adding the as.numeric() call should make the function work for both input types.