Is there and R function for recording variables? : I’m making the leap from SPSS to R but having a few teething issues.

For example, I’m trying to record a variable but I’m getting error messages. I can select cases easily enough. Is it a similar process?

Here’s the SPSS code I’m trying to translate:

RECODE income (1, 2 = 1) (3, 4 = 2) INTO income2.
EXECUTE.
 
CROSSTABS income2 by income.
 
* Recode to String.
STRING sex_values (A8).
RECODE sex (1 = 'Male') (2 = 'Female') INTO sex_values.
EXECUTE.
 
CROSSTABS sex_values by sex.

Grateful for any pointers as I think I’ve confused myself. 

Cheers. 

