How to change from integer (empty) to 0 in r

Viewed 26

How can I create a condition so that if a variable returns the value (empty) in r, it will convert to an actual 0, so I can include it in a larger data frame that will display the value '0' for that variable?

I do not know which variables will return empty, so I want to include this as a condition on all variables before I run the code.

Here is what I have:

groups_ba = df$unique_groups[groupdata_unique$`Appointment Type`=="BA GROUP"]

If the data contains the appointment type 'BA GROUP', I want the value of groups_ba to correspond to the number of BA GROUP, which it currently does. However, if the data does not contain the appointment type 'BA GROUP', I want the value of groups_ba to be 0, rather than what it currently gives me, which is 'empty'.

0 Answers
Related