I am trying to generate a new column based on grouping variables in R.
I have a data frame of test results where each student's end of year exam results are in one row.
Students are in two groups A and B. Group A were taught Chemistry in Semester 1 then English in Semester 2, and Group B were taught the other way round. The exam results are all from the end of the year.
ID Group English Chemistry
1 A 9 4
2 B 7 3
3 B 7 6
4 A 3 10
etc
I want to see if the order of teaching results in differences in exam scores, so I need a column called Sem1 that Includes Group A's Chemistry test and Group B's English, and another column called Sem2 that includes Group A's English and Group B's Chemistry.
so it would look like this:
ID Group English Chemistry Sem1 Sem2
1 A 9 4 4 9
2 B 7 3 3 7
3 B 7 6 6 6
4 A 3 10 10 3
etc
I could then do statistics based on Semesters. I suspect this is not difficult but I am simple. All help appreciated!