How to group and order columns in r
The R code below should help you clean your data.
Please note that I made some assumptions -- see the comments.

library(dplyr)
df = read.delim(['Path to your data'], sep = ",")

# I am making the assumption that record can be uniquely identified by the gameid, drive and down variable

df_drive = df %&gt;% group_by(GameID) %&gt;% mutate(max_drive = max(Drive), min_drive = min(Drive)) %&gt;% select(GameID,Drive, down, max_drive, min_drive)
df_down = df %&gt;% group_by(GameID, Drive) %&gt;% mutate(max_down = max(down), min_down = min(down)) %&gt;% select(GameID, Drive,down, max_down, min_down) 

# Max and Min List
min_max = inner_join(df_drive,df_down,by=c("GameID","Drive","down")) 

# Determine first and last row for each GameID
keep = min_max %&gt;% mutate(idx = ifelse(Drive==min_drive &amp; down == min_down, 'first', ifelse(Drive==max_drive &amp; down == max_down, 'last', 'other'))) %&gt;% filter(idx %in% c('first','last'))

games = inner_join(df, keep, by=c("GameID","Drive","down")) 
games %&gt;% filter(idx == 'first') %&gt;% mutate(field_goal = ifelse(PlayType=='Field Goal','yes','no')) %&gt;% select(GameID,yrdln, field_goal)

# I am making the assumption that sp and down will come from the last record.
first_play = games %&gt;% filter(idx == 'first') %&gt;% select(GameID,yrdln) %&gt;% rename(first_play_yrdln = yrdln)
last_play = games %&gt;% filter(idx == 'last') %&gt;% mutate(field_goal = ifelse(PlayType=='Field Goal','yes','no')) %&gt;% select(GameID,Drive,yrdln, field_goal, sp)  %&gt;% rename(last_play_yrdln = yrdln)

df_final = inner_join(first_play, last_play , by=c("GameID")) %&gt;% select(GameID, Drive, first_play_yrdln, last_play_yrdln, field_goal, sp) 
df_final


You should get:

      GameID Drive first_play_yrdln last_play_yrdln field_goal sp
1 2009091000     2               22              33        yes  1
2 2009091001     1                5              10         no  1