Question: I am using R and I need help adding a row with a couple conditionals. I'm analyzing basketball data (basketball knowledge is not necessary to

I am using R and I need help adding a row with a couple conditionals. I'm analyzing basketball data (basketball knowledge is not necessary to solve this problem). Basically on plays where shootingPlay == "TRUE" and type.text== ("JumpShot" or "LayUpShot") and scoringPlay=="TRUE" I want the value in a new row (call it "event.type") to be "make". When shootingPlay == "TRUE" and type.text== ("JumpShot" or "LayUpShot") and scoringPlay=="FALSE" I want the value in the new row to be "miss". For all other rows, I want the value to be NA.

If the logic for the variable type.text== ("JumpShot" or "LayUpShot") makes it more difficult "points>1" should work equally well. The head of the data frame is included below.

I am using R and I need help adding a row with

# A tibble: 255 x 3 shootingplay points type. text sint> 1 TRUE 2 Jumpshot 2 FALSE O Defensive Rebound 3 TRUE 2 Jumpshot 4 FALSE 0 Defensive Rebound 5 TRUE 3 Jumpshot 6 TRUE 3 Jumpshot 7 FALSE 0 Defensive Rebound 8 TRUE 3 Jumpshot 9 FALSE 0 Defensive Rebound 10 TRUE 2 Jumpshot # A tibble: 255 x 3 shootingplay points type. text sint> 1 TRUE 2 Jumpshot 2 FALSE O Defensive Rebound 3 TRUE 2 Jumpshot 4 FALSE 0 Defensive Rebound 5 TRUE 3 Jumpshot 6 TRUE 3 Jumpshot 7 FALSE 0 Defensive Rebound 8 TRUE 3 Jumpshot 9 FALSE 0 Defensive Rebound 10 TRUE 2 Jumpshot

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!