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
- You create a matrix by column-binding the vectors
- 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 of
team_seedbut R rightly complains that this is an atomic vector (a matrix is a vector with a
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.