You could use ifelse()
on the column, changing all values at once.
gss.s$abany <- ifelse(gss.s$abany == "YES", 1, -1)
gss.s
## abany advfront arrest
## 2 1 Agree NO
## 3 1 Strongly agree YES
## 10 1 Agree YES
## 16 1 Agree NO
## 21 -1 Strongly agree NO