Findinterval Error

Hello,
I'm new with R programming and struggling to fix and error with my predecessors script. Below is the section that is thowing the following error:

"Error in findInterval(hash1, hash2) :
'vec' must be sorted non-decreasingly and not contain NAs"

CODE:
MeditechRvus$ActualIndex <- survival::neardate(as.character(MeditechRvus$CPT),
RvuValues$HCPCS,
MeditechRvus$Service,
RvuValues$EffectiveDate,
best="prior")

I don't see anything stating findinterval anywhere in the 8 scripts comprising this package. However, I have read that survival::neardate is similar. Does anyone know how to interpret this error message and how I should reword this chunk of code?

Thank you very much,
Frank

After you run the code to the line where it would error, could you then on the console write rlang::last_error() in case it has useful info?

Other than that I would try to read the documentation of the function to read if it has explicit requirements.

As a last resort calling debug(survival::neardate) and then running the code to the error line should cause studio to go into debug mode and let one step into and through the problematic function to see what goes on in there.

When I use > rlang::last_error() after I run the piece of code that error out I get the following:
Error: Can't show last error because no error was recorded yet

I did call debug(survival::neardate) and run the code but it does not show any error. It just runs through it without any feedback. The only thing I do see is at the top it says 'Debug location is approximate because the source is not available' ?

Any more thoughts?

Thank for your input and sharing the knowledge.

Frank

fhosea, reading your error message it seems obvious the complaint relates to some function within survival::neardate that requires its inputs to be a certain way. sorted ascendindly with no NA's.
Therefore in your place I would investigate whether your inputs have NA(s) (should they conceptually ?)
Also is there any ordering in your data ? should there be? should there not be ?

For any deeper help than these sorts of suggestions of what to consider, I believe a small reprex would be required.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.