I am trying to write a loop that takes variables in a column of one table (table x) and use those names as column names in another table (table y) and then populate those columns based on certain criteria. Here is my code. I have been attempting to use a For Loop.
for(player in x)
{
y$paste0(x$player)<-ifelse(y$Playing=="True", 1, 0)
}
The error I am getting is "invalid function in complex assignment"
I am working with sports data. My end goal is to count the amount of passes each player was on the field for. I will need to assign the variable 1 for players while they are on the field and a 0 if they are on the bench. Any help would be greatly appreciated.