Hi Muzna, If I understand your question, it's not really about melting or casting, but about re-ordering. Try this:
canefile <- canefile[order(canefile$value), ] see ?"[" and ?order HTH, Ista On Thu, Mar 10, 2011 at 2:20 PM, Muzna Alvi <muzna.a...@gmail.com> wrote: > I have a dataset that is based on crop output for a single crop > *sugarcane*...but > each observation is further subdivided into 3 kinds of sugarcane > i have read the file and have also used melt it to sort it on the > basis of *crop > group* using > > melt(sugarcane, m=c("Crop_group")) -> canefile > > this is how it has cast the data > > variable value > 1 Crop_group Sugarcane (first ratoon) > 2 Crop_group Sugarcane (planted crop) > 3 Crop_group Sugarcane (planted crop) > 4 Crop_group Sugarcane (second ratoon) > 5 Crop_group Sugarcane (first ratoon) > 6 Crop_group Sugarcane (planted crop) > > > now i need to *cast *the data so that i can have each of the 20 odd > variables sorted according to the 3 subdivisions under *Crop_group *ie first > ratoon), second ratoon etc etc.. > > i tried using > > cast (canefile, ~value) -> canefile > > but it said "Aggregation requires fun.aggregate: length used as default" > > i want to cast it on all the 20 variables and sort it on the basis of first > ratoon, second ratoon and planted crop > > How i do my CAST command? > > I hope my question is clear...thanks in advance > > * > * > * > * > -- > -- > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org 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. > -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org ______________________________________________ R-help@r-project.org 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.