i just started using R. I merged 54 files (54 subjects) each 7 variables (data from a behavioral experiment) into one R dataframe.
i now have the variables trial (1 to 210) reaction-time, choice and others in one table starting from subject 1 to 54.
my problem is that i do not have a subject variable (subject ID).
is there any easy way to add a subject variable to the dataframe where already all subjects are in (subject 1 to the first 210 trials (rows) subject 2 to next 210 rows... and so on)
my plan is to use maybe a loop function that adds a variable with the value 1 to the dataset from row 1 to 210 and than a variable 2 to the next 210 rows and so on until subject 54 (row 10920).
thank you very much for your help and best wishes