You don't really have an "ID" variable, so you need to create one. It will be easier if Year
was a character
variable, so I've done that transformation below, in addition to adding an "ID" variable:
d <- within(d, {
Year <- as.character(Year)
ID <- ave(Year, Year, FUN=seq_along)
})
From here, it is easy to use dcast
directly...
library(reshape2)
dcast(d, ID ~ Year, value.var="FQ")
# ID 1975 1977 1979 1981 1983
# 1 1 3.156 10.304 4.729 4.856 9.887
# 2 2 8.980 7.861 7.216 3.438 3.850
... or reshape
.
reshape(d, direction = "wide", idvar="ID", timevar="Year")
# ID FQ.1975 FQ.1977 FQ.1979 FQ.1981 FQ.1983
# 1 1 3.156 10.304 4.729 4.856 9.887
# 62 2 8.980 7.861 7.216 3.438 3.850