I don’t see the question here, but if it bothers you much, there are several alternatives.
R xtabs ( ) .
as.data.frame.matrix(xtabs(Value ~ Name + Year, long))
, , dcast "reshape2".
library(reshape2)
dcast(long, Name ~ Year)
, , , . reshape, , . , "" , :
> long$Something <- 5:8
> reshape(long, timevar = "Year", idvar = "Name", direction = "wide")
Name Value.1996 Something.1996 Value.1997 Something.1997 Value.1998
1 a 1 5 2 6 NA
3 b NA NA NA NA 3
Something.1998 Value.1999 Something.1999
1 NA NA NA
3 7 4 8
, , , 1996 "", "-".
, reshape ( ), ( , "" ), :
setNames. , : , .
> setNames(reshape(long, timevar = "Year", idvar = "Name", direction = "wide"),
+ c("Name", long$Year))
Name 1996 1997 1998 1999
1 a 1 2 NA NA
3 b NA NA 3 4
sub gsub, . , , , , , .
> wide <- reshape(long, timevar = "Year", idvar = "Name", direction = "wide")
> names(wide)
[1] "Name" "Value.1996" "Value.1997" "Value.1998" "Value.1999"
> names(wide) <- gsub("Value.", "", names(wide))
> wide
Name 1996 1997 1998 1999
1 a 1 2 NA NA
3 b NA NA 3 4