R merge even/odd rows I need to merge eve/odd rows on a data set.

Example:

      match team count points
    1     1  ARG    11     21
    2     1  ENG     9     19
    3     2  CAN     8     15
    4     2  USA     8     17
    5     3  FRA     7      7
    6     3  NZL     8     36


To:

      match team1 t1p t1s team2 t2p t2s
    1     1   ARG  11  21   ENG   9  19
    2     2   CAN   8  15   USA   8  17
    3     3   FRA   7   7   NZL   8  36


This is my current solution:

odd &lt;- all_scores[seq(1, nrow(all_scores), 2),]
colnames(odd) &lt;- c("match", "team1", "t1p", "t1s")
even &lt;- all_scores[seq(2, nrow(all_scores), 2),]
colnames(even) &lt;- c("match", "team2", "t2p", "t2s")
new_scores &lt;- merge(odd, even)


Is there an easier, more space efficienct, or more R-like way to do this?
Have a look at the reshape function. To use the jargon, your data is in "long" format and you want to turn it to a "wide" format. Before using reshape, you will need to add a column of 1, 2, 1, 2, etc. so it can be used as the "time" column. You can do that on the fly using the transform function. In all:

new_scores &lt;- reshape(transform(all_scores, i = 1:2),
                      idvar = "match", timevar = "i", direction = "wide")

#   match team.1 count.1 points.1 team.2 count.2 points.2
# 1     1    ARG      11       21    ENG       9       19
# 3     2    CAN       8       15    USA       8       17
# 5     3    FRA       7        7    NZL       8       36