My input data is in the format shown in the left column. I would like the data to be in the format shown in the right column.
How can I do that?
Here is my dput:
structure(list(Player = structure(c(7L, 16L, 13L, 9L, 12L, 15L,
11L, 6L, 2L, 3L, 10L, 8L, 4L, 1L, 5L, 14L), .Label = c("Alberto Castillo\\castial01",
"B.J. Surhoff\\surhob.01", "Bobby Bonilla\\bonilbo01", "Chipper Jones\\jonesch06",
"David Segui\\seguida01", "Eddie Perez\\perezed02", "Felix Jose\\josefe01",
"Garret Anderson\\anderga01", "John McDonald\\mcdonjo03", "Keith Lockhart\\lockhke01",
"Luis Gonzalez\\gonzalu01", "Mark Grace\\gracema01", "Matt Williams\\willima04",
"Melvin Mora\\morame01", "Steve Finley\\finlest01", "Tony Clark\\clarkto02"
), class = "factor"), G = c(13L, 36L, 44L, 70L, 145L, 150L, 155L,
16L, 25L, 114L, 128L, 135L, 143L, 11L, 18L, 125L), Year = c(2002L,
2009L, 2003L, 2012L, 2001L, 2002L, 2005L, 2005L, 2002L, 2000L,
2002L, 2009L, 2009L, 2007L, 2004L, 2009L), Age = c(37L, 37L,
37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L, 37L,
37L)), class = "data.frame", row.names = c(NA, -16L))