Q5 How to convert different level to same level in R?

r

#1

I am currently solving one classification problem for doing it I am looking into different variable .

table(char_df$Local.or.global.player,useNA="always")

 global  Global  GLObaL  GLOBAL   local   Local   LOCAL local      <NA> 
     90      93       2      52      95      99      16       1      24

There are only two level in this categorical variable (GLOBAL and LOCAL).I want to know how convert , so many levels into two different levels.


#2

hello @harry,

Please see below:

df <- data.frame(location = c("Global","global","gloBAL","GLOBAL","local","LOCAL"))
levels(df$location)[1:4] <- "global"
levels(df$location)[5:6] <- "local" 

This converts the levels.