[R] Reformat a data frame

Gabor Grothendieck ggrothendieck at gmail.com
Tue Nov 7 23:23:53 CET 2006


In addition to the reshape solution posted one could use melt from
the reshape package:

melt(df1, id = 1:2)



On 11/7/06, Thorsten Muehge <MUEHGE at de.ibm.com> wrote:
>
> Hello Experts,
> how do I reformat a data frame in the way described below:
>
>
> df1:
> ID    desc  resist      thick temp
> 1     4711  100   5     20
> 2     4712  101   4     21
> 3     4711  99    3     19
> 4     4712  98    7     22
>
> TO
>
> df2:
> id    desc  Param Value
> 1     4711  resist      100
> 1     4711  Thick 5
> 1     4711  temp  20
> 2     4712  resist      101
> 2     4712  Thick 4
> 2     4712  temp  21
> 3     4711  resist      99
> 3     4711  thick 4
> 3     4711  temp  19
> 4     4712  resist      98
> 4     4712  thick 7
> 4     4712  temp  22
>
> Thanks a lot for your help.
> With best regards
> Thorsten
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> 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.
>



More information about the R-help mailing list