The code I'm using is: require(reshape) DF2 = melt(DF, id.vars = c('year', 'month', 'day'), measure.vars = c('site1_elev', 'site2_elev', 'site1_temp', 'site2_temp'))
But it didn't work. On Sat, Oct 22, 2016 at 11:50 AM, lily li <chocol...@gmail.com> wrote: > 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]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.