[R] About reshape dataset
lily li
chocold12 at gmail.com
Sat Oct 22 19:52:28 CEST 2016
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 <chocold12 at 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]]
More information about the R-help
mailing list