[R] About reshape dataset

lily li chocold12 at gmail.com
Sat Oct 22 19:50:10 CEST 2016


Hi R users,

I want to melt a dataframe, but it mixed up the variables.

DF is the original dataset:
year  month  day  site1_elev  site2_elev  site1_temp  site2_temp
2000     5        6        1300          1500            20              21

2000     5        7        1300          1500            21              22
2000     5        8        1300          1500            19              20
2000     5        9        1300          1500            22              23

How to melt the dataframe and get the following dataset? Thanks for your
help.

year  month  day  siteID   elev   temp
2000    5         6       1      1300    20
2000    5         6       2      1500    21
2000    5         7       1      1300    21
2000    5         7       2      1500    22

	[[alternative HTML version deleted]]



More information about the R-help mailing list