First, my apologies for what is probably a very basic question, but I'm an absolute beginner with R. Also, apologies if I use incorrect terminology; I'm a SAS programmer and tend to use those terms.
I have a character date variable that may contain year only ("2020"), or year and month ("2020-11"), or may be a complete date ("2020-11-24"). I need to impute the incomplete dates to the end of the year if we have year only ("2020" becomes "2020-12-31"), or to the end of the month if we have year and month only (which of course will depend on which month it is; and if February, also what year it is).
Please tell me there's a quick and easy way to do this. I'm not concerned about the year-only dates, since that would be simply pasting on "-12-31" in all cases. I figured out how to substring out the month for the year + month dates, but am having a hard time coming up with a way to use this in an if-else situation . And I'm not even looking at dealing with February yet...that's why I'm hoping there's an existing function, or some easy way to do this.
Thank you!!