0

My data describes the rankings of preferred video game platform for 91 people. There are 6 consoles, so the df is 91x6, with each column being a console and the values being the ranking (1=most preferred, 6=least preferred).

Basically, the headers look like this:

xboxrank PSrank PSPrank PCrank Gameboyrank Gamecuberank

I need to create a column that just contains each person's favorite console (i.e. for each row, the column containing "1" indicated that the console represented by that column is the person's favorite). So, I need each person's favorite console, ideally as text (i.e. I'd have a variable "FavConsole" or something containing the actual names of each person's favorite console.

I'm pretty new to R and could figure this out in Stata, but for work purposes I need to do this in R.

  • Maybe this? https://stackoverflow.com/q/17735859/ (except you're looking for min not max) – Frank Apr 25 '18 at 19:03
  • That's helpful. I suppose I could rename the columns and then have the name of the min column returned – oracle_randy Apr 25 '18 at 19:20
  • Alternately, you could rename afterwards, eg with `substr(x, 1, nchar(x)-4)` or similar removes the last four characters. – Frank Apr 25 '18 at 19:22

0 Answers0