I am trying to create a dummy variable from a factor variable which looks about like this:
[1] cva accident w rt hemiparesis aphasial dm type ii htn
6589 Levels: cva accident w rt hemiparesis aphasial dm type ii htn ...
This is the code I have used to create the dummy variable:
random_merge_patients$'MedCond_HTN' <- ifelse(random_merge_patients$'MedCond' %in% "htn",1,0)
I receive no error messages but when I try to view random_merge_patients$'MedCond_HTN'
I see that the values are all 0s even if there should be some 1s .
Any ideas what could be wrong with my code?