Relative Content

Tag Archive for rfor-loopiterationrstudiogrouped-table

Loop over grouped data in R

I have two dataframes, one where id is a primary identifier and the other is long data. I merged both and so I have long data (this can be reversed). I grouped the data based on id and want to loop over each group, generating a new variable value for each row in a group based on some condition. For instance, I want to loop over the group with id = '0000' and for each row in that group, if alx is greater than 80, my new_variable = True