I'd like to turn this:
game_date team_id opponent_id team_away team_outcome opponent_outcome
1 2016-03-09 a b FALSE loss win
structure(list(game_date = "2016-03-09", team_id = "a", opponent_id = "b",
team_away = FALSE, team_outcome = "loss", opponent_outcome = "win"), .Names = c("game_date",
"team_id", "opponent_id", "team_away", "team_outcome", "opponent_outcome"
), class = "data.frame", row.names = "1")
Into this:
game_date team outcome away
2016-03-09 a loss FALSE
2016-03-09 b win TRUE
I'm having trouble determining the best way to do this with reshape
. I've tried for example
dcast(x, team_id + opponent_id ~ team_outcome)
melt(x, id.vars = c("team_id", "opponent_id"), measure.vars = c("team_outcome", "team_away")