W
W
wolverine7772019-09-16 18:26:21
R
wolverine777, 2019-09-16 18:26:21

How to reduce the number of levels in a factor?

Hello, in my dataframe with movies in the column "Genre" in the factor of 15 levels:
levels(dann$Genre)
> levels(dann$Genre)
[1] "action" "adventure" "animation" "biography" "comedy" " crime"
[7] "documentary" "drama" "fantasy" "horror" "musical" "mystery"
[13] "romance" "sci-fi" "thriller"
I need to reduce the number of levels from 15 to 5 (leave action, adventure, animation, comedy, drama)
Thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmshar, 2019-09-16
@dmshar

Where are the rest to go?
Those.
Option 1 - you simply throw out all the films classified in 10 categories that you are not interested in.
Option 2 - you "scatter" films of "uninteresting" categories into 5 interesting categories. The scatter algorithm is your concern.
I don't see anything else.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question