Creating a New Variable from Two Variables

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Creating a New Variable from Two Variables

Greetings Everyone,

First off, let me apologize for this simplistic question. I have been using SAS and SPSS for so long that I am having trouble transitioning to R.

I have two variables Race and Ethnicity. I want to create a whole new variable in my data set that is Race/Ethnicity. For the most part I want the Race column to remain unchanged. The only difference in this new variable is that if Hispanic or Latino shows up in the Ethnicity category I want it to over write whatever might be present in the race category.

Please see the image above. I would want the Hispanic or Latino to overwrite the American Indian or Alaska Native. However, if the Ethnicity was any other category than Hispanic or Latino I would want the race category remain changed.

Any one have any ideas on how I can do this best?

Warm Regards,