0
$\begingroup$

I have to work on this database on R. I have tried to make a tree model, but all the variables are factors with too many levels. I tried changing the column "operator" in three levels (keeping private, having military for all "military - state" and air company for all the others) using something like getData$operator[grep("Military", getData$operator)] <- "Military" but it changes into NAs since it's not a valid factor.

I could change it to string and make it work, but it doesn't solve the "if not rivate or military, change to air company" part. Is there any other way?

$\endgroup$
1
$\begingroup$

Make a new column equal to „company“. Use the grep to replace military by „military“, use the grep to replace private by „private“. Change the new column to a factor.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.