You're getting the correct answer, just reading it wrong.
look at the whole output:
> tapply(df$y, df$x, sum)
1 2
3 3
Your groups are 1 and 2 and the values are 3 and 3. Is horizontal. You can see this if you try tapply
in the other direction
> tapply(df$x, df$y, sum)
1 2 3
1 1 2