Need help recoding a varaible in R

Getting started with R and I would like to recode the variable to just leave two categories male and female. Can someone help me do this in the simplest way.

Hi, and welcome.

A reproducible example, called a reprex would improve my confidence in one possible solution:

no_na_ <- year[!is.na(year$Factor), ]

which will remove all NA valued entries from the year object.