The problem is relatively simple. You have
team_seed <- data.frame()
team_seed <- cbind(playoff_teams, seed_col, BPI_col)
head(team_seed$seed_col)
If we break this down you’ll see the problem:
- You create an empty data frame and assign it to the object
team_seed
- You create a matrix by column-binding the vectors
playoff_teams
,seed_col
, andBPI_col
. - You assign this matrix to the object
team_seed
, thus obliterating the empty data frame you created in the first line. R just overwrote it. - You then try to
head()
a component ofteam_seed
but R rightly complains that this is an atomic vector (a matrix is a vector with adim
attribute)
What you want is some variation on:
team_seed <- data.frame(playoff_teams, seed_col, BPI_col)
there is no reason to allocate the empty data frame. If you do that, then you need to fill in the data frame, not overwrite it.