I thought the "mutate" function would add a column to the dataframe. But in Lab 06, the team.budget and cost.p.win columns that I create in step 3 seem to disappear by step 4. Here's what I did:
# Step 2: Join Salaries & Teams
dat.comb <- Salaries %>%
left_join(Teams, by = c("teamID", "yearID"))
Then when I move on to Step 4, team.budget and cost.p.win have disappeared. (Even though I don't have any other commands between step 3 and step 4.) If I run this:
I get the error: "Error: Can't subset coluns that don't exist. X Column 'team.budget' doesn't exist...."
Same thing if I comment out team.budget, except it says "X Column 'cost.p.win' doesn't exist.
Am I misunderstanding how mutate works? Or am I using it wrong? If I add the mutate command back into step 4, it works:
(Yes, I know it's returning too many lines for each team, which is the next thing I'll try to figure out.)
But if I created team.budget and cost.p.win with mutate in step 3, shouldn't I be able to just use them in step 4 without having to create them again? What am I missing? Thanks for any clarification you can offer!
I thought the "mutate" function would add a column to the dataframe. But in Lab 06, the team.budget and cost.p.win columns that I create in step 3 seem to disappear by step 4. Here's what I did:
Which produces:
Then when I move on to Step 4, team.budget and cost.p.win have disappeared. (Even though I don't have any other commands between step 3 and step 4.) If I run this:
I get the error: "Error: Can't subset coluns that don't exist. X Column 'team.budget' doesn't exist...." Same thing if I comment out team.budget, except it says "X Column 'cost.p.win' doesn't exist.
Am I misunderstanding how mutate works? Or am I using it wrong? If I add the mutate command back into step 4, it works:
(Yes, I know it's returning too many lines for each team, which is the next thing I'll try to figure out.)
But if I created team.budget and cost.p.win with mutate in step 3, shouldn't I be able to just use them in step 4 without having to create them again? What am I missing? Thanks for any clarification you can offer!