dataframe - R - Running Score Column For Sports Results -


I have a large dataset of goals given in football matches, which are sorted by match and in which order were scored Were. This is in the following format: Currently I have only the first 2 columns, the third is what I am struggling to create:

  goal. Equation Target Deviation is going on. Differentiated 0 0 0 1 1 1 2 -1 0 0 0 0 0 1 1 1 2 1 2 3 -1 1 4 1 2 25 0 2 0 0 -1 -1 -1 2 -1 -2 25 0 -2  

Each row with a sequence number 0 or 25 indicates a goal except for any row (these matches are the dummy rows for the starting point and match-end point). Round Defense column shows the goal of home teams (+1 if they scored, -1 if they have agreed). Therefore, the sample data given above represents 3 different matches, which resulted in 1-1, 3-1 and 0-2.

I want to make the third column for the score difference in the match, but every new match that is restarted, I am struggling to do this and any help would be appreciated.

Some examples follow the data:

  Provide data in # usable format (such as using dput on your data object) score & lieutenant; - Structure (list (target. Sufficiency = C (0L, 1L, 2L, 25L, 0L, 1L, 2L, 3L, 4L, 25L, 0L, 1L, 2L, 25 L), target 0L, 1L, -1L, 0L, 0L, 1L, 1L, -1L, 1L, 0L, 0L, -1L, -1L, 0L )). Name = C ("Target. Inequality", "Target. Differential", "Match"), Line.Name = C (NA, -14L), class = "data.frame")  

If you create a label, which indicates which one line matches its part:

< Pre> labl & lt; - cumsum (df $ Goal.Sequence == 25)

Then you

  Away (df $ Goal.Difference, labl, FUN = cumsum) Through a mail-based cumsum can  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -