Applying a formula to an entire table in R -


Hello all I have come back with another issue concerning R. So the problem happens in this way, the performance table of players is in a soccer match with different players, the number of failures calculated about each player, goals, etc. ..

I think the player's rating I want to apply a formula to measure:

  player_reating = (target + 0.5 + assistant + 0.5 * shots at target - 0.2 * officially done - 0.8 * red card - 0.4 * Yellow card + 0.2 * saves)  

The output needs to appear in the table with the data in the form of a new column, assuming that the player is called player_violence

before:

< The goal of the pre name is Yellow.card A 0 B 0 2 C2 1

after:

  The name of the target Yellow.card Player_rating 1 0 15B 2 2 5C2 1 26  

thanks

From the table, I consider it a data frame. Here I have created a dummy data frame with the field you specified.

  df < - Data = frames (targets = 4:10, help = 5:11, shot = 1: 7, foul = 7: 1, red = sample (1: 3, 7, location = t), yellow = sample (3: 7, 7, Change = T), = Saves Sample (1:10, 7, Change = T)) M & LT; - DF * C (1,0.5,0,5, -0.2, -0.8, -0.4,0.2) DF & lt; - cbind (df, player_rating = rows (m))  

I've taken an intermediate item m , you can leave it.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -