Here's a reproducible example, with my explanation of why it does what it does.
data = read.csv(text="Email foo.final bar.final
[email protected] 100 200
[email protected] 101 201
[email protected] 102 202
[email protected] 103 103", header=T, sep="" )
a = gather(data, key, Grade, -Email)
means: Except "Email", put the values of all the columns into a single new column called "Grade" and add a new column called "key" which contains the column header under which the value occurred. Given that we have 4 observations with two variables each, that should produce 8 observations. Result:
Email key Grade
1 [email protected] foo.final 100
2 [email protected] foo.final 101
3 [email protected] foo.final 102
4 [email protected] foo.final 103
5 [email protected] bar.final 200
6 [email protected] bar.final 201
7 [email protected] bar.final 202
8 [email protected] bar.final 103
b = gather(data, key, Grade)
Same meaning but now we include Email. Now we have 4 observations but with 3 variables, so we should get 12 observations. Result:
key Grade
1 Email [email protected]
2 Email [email protected]
3 Email [email protected]
4 Email [email protected]
5 foo.final 100
6 foo.final 101
7 foo.final 102
8 foo.final 103
9 bar.final 200
10 bar.final 201
11 bar.final 202
12 bar.final 103
I am not surprised.