My data set looks something like this:
Movie Name | Genre #1 | Genre #2 | Genre #3 | MovieBudget |
---|---|---|---|---|
Movie1 | 0 | 1 | 1 | 2500000 |
Movie2 | 1 | 0 | 0 | 3430000 |
Movie3 | 1 | 0 | 1 | 1240000 |
I am trying to find which genre has the highest budget. For example, in the example dataset the film with the highest MovieBudget is Movie 2. Ideally, I would get that information outputted like:
Movie Name | Movie Budget | Genre #1 |
---|---|---|
Movie#2 | 3430000 | 1 |
If it was a film that had two genres then there would be an additional column for that second genre.
I’ve attemped by setting a general variable with all the genre categories equaling 1 but that didn’t work.
bool<- raw_data |> c(Crime!=0, Drama!=0, Western!=0, Biography!=0, History!=0, Adventure!=0, Fantasy!=0, Mystery!=0, SciFi!=0, Romance!=0, Thriller!=0, War!=0, Family!=0, Animation!=0, Comedy!=0)
raw_data |> slice_max(InflatedBudget) |> select(FilmName, Year, InflatedBudget, InflatedGross, raw_data[bool])
When I use the code above I get:
Error: object ‘Crime’ not found
I don’t have much experience with R so I’m not quite sure where to even start.
New contributor