I have a dataset with 77 columns and some of them have categorical values (for ex. the column 'Sexual Orientation' can have one of the following values: 'Heterosexual', 'Homosexual', 'Bisexual', 'Other', 'NA'). (I also have some NAs that I will impute after I will have reshaped my data frame).
I want to transform this dataset into a dataset that only have binary values. So, for example, I want the above column to be divided into 4 different columns that say:
Heterosexual Homosexual Bisexual Other 1 0 0 0
or, if I have an NA row, I want it to be represented as following:
Heterosexual Homosexual Bisexual Other NA NA NA NA
Also, I have 'binary' variables like "Gender" (I only have the values 'Male' and 'Female') and I want this column to be split into two different columns like this:
Male Female 0 1
or, in the case of NA:
Male Female NA NA
Is there a function that I can use to do this? My professor told me that the function 'reshape' could help me doing it but I have had some troubles using it and I don't think it would work.
Could you please give me any advice? thank you in advance