Skip to content
Prev 304217 / 398503 Next

Changing entries of column of type "factor"/Adding a new level to a factor

Hi

you could save yourself time to read help page for factor
data.frame is not a matrix

each factor have levels attribute
levels(input$M1)
level 0/0 shall be the first so
levels(input$M1)[1] <-"999/999"

Easiest way is probably cycle through columns of your data

for( i in columns) levels(input[,i])[levels(input[,i])=="0/0"]<-"999/999"

Regards
Petr