Filtering giving me error, "arguments imply differing number of rows"

Hello,

I am working with a data set, where I am evaluating dates. After some manipulation, I got a data frame which contains deltas (difference between two dates) or NA's. Unfortunately I can't create a reprex, but filtering is behaving strange and I don't know why.

To try and better exemplify the issue I'm encountering, I will try and provide SS that illustrate what is happening the best I can.

In this first screenshot, I pull the str() and head() to exemplify the data I'm working with. Also to show that the variable types are all handled, there isn't (to my knowledge) any weird variable type messing things up.

The goal was to identify the what observations the values are NOT NA or 0, therefore I decided to just use filter() and write for each variable the conditions as there wasn't that many variables to handle and I suck using apply() or loops easily.

For the first 2 variables, eta_dp_date_delta13 and eta_dp_delta15, it seemed to have worked.

So I kept on going adding all the variables "blocks" that are commented out on the code seen above.

After writing everything out I tried to get output and the code gave me an error, I've never seen before.

Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, :
arguments imply differing number of rows: 0, 1

So I began troubleshooting commenting out sections to see what was happening. After some troubleshooting and trying things online, I commented out the 3 blocks that are causing the error. If I include any of the below commented out "blocks" (the filter pairs), I get the error. Can't understand why.

Below is screenshot with the error if that makes any difference.

Any insight on what could be causing the issue?

Side question, is there a more elegant "loop way" to check all columns and bring back only observations that are NOT 0 or NA?

Thanks for your time and help.

See the FAQ: How to do a minimal reproducible example reprex for beginners. Questions illustrated only by screenshots and descriptions are likely to go unanswered.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.