I am trying to convert SAS script to R to learn R. Below is the script in SAS.
if continent=1 and (country=5 or country=10) then rate = 8
data$rate[(continent==1) & (country==5 | country==10)] <- 8
data$rate[(continent==1) & country %in% c(5,10)] <-8
It looks like your issue is that you did not call the variable from the data from the dataframe
data. This may be the cause of your error. To fix this, specify the variable within the dataframe by doing:
data$rate[(data$continent==1 & (data$country==5 | data$country==10))] <- 8