Straight to the situation:
I am working with football tracking data, I have a list of events and within each element is recorded different situation of the game. I am interested in the passes that were made. I have for loop to iterate through the list and get me each pass for the specific team.
for (p in 1:length(uruguay.passes)){
uruguay.pass.temp <- all.events[[uruguay.passes[p]]]
possession <- uruguay.pass.temp$possession
passer <- uruguay.pass.temp$player$id
.
.
body.part <- uruguay.pass.temp$pass$body_part$name
Here comes the problem: Sometimes data for passer or another attribute would be missing and it messes up the whole row. Here is a screenshot.
Here comes the question: How can I write an if statement that checks if that specific attribute i.e. Passer is present within the element and if is not present to populate the column with NA?
Thank you everyone!
Aucun commentaire:
Enregistrer un commentaire