use ifelse() function in R to create dummy variables and categorical variables