One of the may way is to recode the variable this way,
Assuming your variable are stored as numeric,
S<- data.frame(a=c(1, 2, 2, 2, 3, 3, 4, 5, 1, 1), b=c(2, 3, 4, 5,2, 2, 4, 1, 1, 2))
#you want to reverse code both and b variable
S[,c(1,2)] <- ifelse(S[,c(1,2)] == 1, 5,
ifelse(S[,c(1,2)] == 2, 4,
ifelse(S[,c(1,2)] == 3, 3,
ifelse(S[,c(1,2)] == 4, 2,
ifelse(S[,c(1,2)] == 5, 1,NA))))