我们可以用dcast
.该...
上的LHS ~
包括未在RHS,并在指定的所有变量value.var
.
library(reshape2) dcast(df, ...~element, value.var='value') # date year month day gridNumber PPT TMAX TMIN #1 1899-12-15 1899 12 15 526228 0.0000 43.4782 21.7403 #2 1899-12-16 1899 12 16 526228 0.0000 43.3297 20.7510 #3 1899-12-17 1899 12 17 526229 0.0000 57.3625 25.8157 #4 1899-12-18 1899 12 18 526229 0.2105 NA NA