So I have a dataset with columns that include name, age and a lot more of information on the players. Since I am pretty new at R I don't know how to write function that does this:
create a function of which the input are two players and the output their Name, age, overall, position, skillmovesrating, and the
6 skill rating(depending on their position the output is different if the player is a goalkeeper.) we just created.
We can extract the data about the player being a goal keeper from a column named Position as "GK" or from a column named Class as "Goalkeeper"
So I wrote this:
Compare_Players<-Function(Player1,Player2){
if((Player1 == "Goalkeeper")){print(Name,Age,Overall,Position,GKDiving,GKHandling,GKKicking,GKPositioning,GKReflexes,Speed,Skill.Moves)} else{print(Name,Age,Overall,Position,Pace,Shooting,Passing,GeneralDribling,Defending,Physical,Skill.Moves)}
ps. the player1 and player 2 input are supposed to come out the column "Name" of my dataset ( df[,1] )
What I want is: Compare_Players(Messi,Ronaldo)
Outcome: both their data on the above mentioned columns