Good evening everyone, I'm stuck on a problem with data transformation that I'd like to share with you.
In tidying the data I am working with, I've successfully refined two data frames with the desirable variables.
I now want to populate a column I have named 'VISIT_DAY', and made into a factor ("YES", "NO). I want to populate it based on the conditions of "PATIENT_ID" and "DATE", depending on them matching in both data frames (i.e. if 'df1' and 'df2' both have an observation with PATIENT_ID 123 and DATE 08-20-2018).
Here is the attempt I have made thus far.
Home.raw4$VISIT_DAY <- factor(Home.raw4$VISIT_DAY, levels = c("YES", "NO"))
Home.raw4$VISIT_DAY <- ifelse((Home.raw4$PATIENT_ID == "-2147483646" & Home.raw4$DATE == "06.08.2018"), "YES", "NO")
When I execute the second line of code, it populates the column with only "NO", even in the observation where conditions are met.
I was wondering if anyone could help me resolve this? It seems like the ifelse() code is somewhat correct, but I feel that I am missing something for it to state "YES" when conditions are met.
I'm quite new to R Studio, so if it is blatantly obvious what I should do, my apologies.
Thanks for reading.