What I need to do, is kind of screening of the DT, and when for each ID:
dose=0 & days >= 30, then the row AND the subsequent rows should be deleted.
And then a screening of the next ID and so on.....for all the 80.000 rows (approx 2000 IDs)
Thanks, Nour: In general it's easier for folks to help you if you paste the data between triple backticks ``` as I described -- could click the pencil icon on your post and insert triple backticks before and after the output?
Almost -- a step in the right direction, but the output from dput() is still incomplete, and make sure you put the ``` by itself on the line before your output, and again by itself on the line after your output.
This is becoming a little frustrating to watch, you are supposed to ask your questions providing a proper REPRoducible EXample (reprex) illustrating your issue.
@dromano:
I mean the subsequent rows for the same ID, i.e. if there is a pause in medication for more than 30 days, then I want to delete this row and all the other rows after this row for the patient.
The issue is that I want only the observations for each patient before the first pause in medication ( a pause is defined as 30 days without medicine "0" or more) but not the other rows afterwards - hope this makes sense...
@andresrcs:
Thank you so much - and sorry I did not see the help section - this is my first time here…
Thank you for the code, but it do not solve my problem, as I get:
Error in days >=30 :
comparison (5) is possible only for atomic and list types
It works with the sample data you have provided, to been able to help you, please read the guide on the link I gave you and provide an example that reproduces your issue.
Did you still need help, or did @andresrcs's solution eventually work for you? If you do still help, it'll be important to get your dput() output in order since what you posted still doesn't work.