Here\'s a sample data frame.
df = data.frame(company = c(\'a\', \'b\', \'c\', \'d\'), bond = c(0.2, 1, 0.3, 0), equity = c
Another option:
df[unique(row(df[-1])[df[-1] == 1L]),] # company bond equity cash #2 b 1 0 0 #4 d 0 1 0 df$company[unique(row(df[-1])[df[-1] == 1L])] #[1] b d #Levels: a b c d