Hi,

I am very new to R so I end up with errors all the time, apologies in advance if this seems like a very basic question.

I have a variable 'patient_yearofbirth' in my dataset. To calculate the age of patients, I thought I could simply subtract 'patient_yearofbirth' from the current year '2020' . I used the following codes:

AZH$current_year<-c('2020') ##created current year variable so that age could be calculated

AZH_with_Age<-AZH

AZH_with_Age$Age<-AZH$current_year-AZH$patient_yearofbirth ##subtracted the two years to get age

But I am getting the following error: "Error in AZH$current_year - AZH$patient_yearofbirth : non-numeric argument to binary operator"

How should I go about it? What does this error imply?

Any help would be much appreciated.