Re: [R] help with colsplit (reshape)

From: hadley wickham <h.wickham_at_gmail.com>
Date: Fri, 13 Jun 2008 16:47:55 -0500

> Right, there is no time associated with this variable. So I tried again,
> treating it as an id:
>
> M.Data <- melt(Data, id = c("pid", "predA"))
>
> From here I was able to achieve the desired result, as follows:
>
> M.Data <- data.frame(M.Data, colsplit(M.Data$variable, split = "\\.",
> names=c("measure", "time")))
> M.Data$variable <- M.Data$measure
> M.Data <- M.Data[-5]
> L.Data <- cast(M.Data, ... ~ variable)
>
> This is perhaps a bit inelegant but it works! I'm interested in knowing if
> there is a better way to do it, but I'm happy that I've at least figured out
> this much. As always I'm humbled by the generosity of people who not only
> make their software available but also take the time to answer questions on
> this list. Thank you!

You're welcome. And don't worry too much about data cleaning routines being elegant - it's very very hard to write elegant code to clean up something that's not at all elegant.

Hadley

-- 
http://had.co.nz/

______________________________________________
R-help_at_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.
Received on Fri 13 Jun 2008 - 23:05:37 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 14 Jun 2008 - 00:30:55 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive