Thank you very much DJ MuseR!
Curtis K ~ Sent from a PDA. I apologize in advance for any typing errors. On Nov 8, 2011, at 4:36 PM, "djmuseR [via R]" <ml-node+s789695n4018171...@n4.nabble.com> wrote: > Here's another approach using the plyr and data.table packages, where > df is the name I gave to your example data: > > # plyr > library('plyr') > ddply(df, .(TIME), mutate, L1 = sort(S1)) > > # Another way with the data.table package: > library('data.table') > dt <- data.table(df, key = 'TIME') > dt[, list(X1, S1, L1 = sort(S1)), by = 'TIME'] > > HTH, > Dennis > > On Tue, Nov 8, 2011 at 11:58 AM, economicurtis <[hidden email]> wrote: > > > I have panel data in the following form: > > > > TIME X1 S1 > > 1 1 0.99 > > 1 2 0.50 > > 1 3 0.01 > > 2 3 0.99 > > 2 1 0.99 > > 2 2 0.25 > > 3 3 0.75 > > 3 2 0.50 > > 3 1 0.25 > > ... ... ...... > > > > And desire a new vector of observations in which one column (S1 above) is > > sorted for each second from least to largest. > > > > That is, a new vector (L1 below) of the form: > > > > TIME X1 S1 L1 > > 1 1 0.99 0.01 > > 1 2 0.50 0.50 > > 1 3 0.01 0.99 > > 2 3 0.99 0.25 > > 2 1 0.99 0.99 > > 2 2 0.25 0.99 > > 3 3 0.75 0.25 > > 3 2 0.50 0.50 > > 3 1 0.25 0.75 > > ... ... ...... ..... > > > > Sorry for the NOOB question, but any help would be great. > > > > Curtis Kephart > > > > -- > > View this message in context: > > http://r.789695.n4.nabble.com/Sorting-Panel-Data-by-Time-tp4017271p4017271.html > > Sent from the R help mailing list archive at Nabble.com. > > > > ______________________________________________ > > [hidden email] 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. > > > > ______________________________________________ > [hidden email] 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. > > > If you reply to this email, your message will be added to the discussion > below: > http://r.789695.n4.nabble.com/Sorting-Panel-Data-by-Time-tp4017271p4018171.html > To unsubscribe from Sorting Panel Data by Time, click here. > See how NAML generates this email -- View this message in context: http://r.789695.n4.nabble.com/Sorting-Panel-Data-by-Time-tp4017271p4018372.html Sent from the R help mailing list archive at Nabble.com. [[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.