Hello all, I have a set of numbers that looks like this:> id <- c(1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 1, 2, 2, 2, 3, 3, 1, 1, 1, 2, 3, 4, > 4, 4, 5, 5) > id[1] 1 1 2 2 2 3 4 4 4 4 1 2 2 2 3 3 1 1 1 2 3 4 4 4 5 5 Please ignore the bold numbers, I just want to make my problem clear. I am going to order them as this: 1 1 2 2 2 3 4 4 4 4 5 6 6 6 7 7 8 8 8 9 10 11 11 11 12 12 Can anyone please help how to get this done? Your help would be greatly appreciated. Lisa -- View this message in context: http://n4.nabble.com/Ordering-numbers-tp941453p941453.html Sent from the R help mailing list archive at Nabble.com.
On Wed, Dec 2, 2009 at 3:30 PM, Lisa <lisajca at gmail.com> wrote:> > Hello all, > > I have a set of numbers that looks like this: > >> id <- c(1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 1, 2, 2, 2, 3, 3, 1, 1, 1, 2, 3, 4, >> 4, 4, 5, 5) >> id > [1] 1 1 2 2 2 3 4 4 4 4 1 2 2 2 3 3 1 1 1 2 3 4 4 4 5 5 > > Please ignore the bold numbers, I just want to make my problem clear. > I am going to order them as this: > > 1 1 2 2 2 3 4 4 4 4 5 6 6 6 7 7 8 8 8 9 10 11 11 11 12 12 > > Can anyone please help how to get this done? Your help would be greatly > appreciated. > > Lisa >Hi, ?sort> sort(id)[1] 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 4 4 4 4 4 4 4 5 5 Senthil
Here is one way:> id <- c(1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 1, 2, 2, 2, 3, 3, 1, 1, 1, 2, 3, 4,+ 4, 4, 5, 5)> id[1] 1 1 2 2 2 3 4 4 4 4 1 2 2 2 3 3 1 1 1 2 3 4 4 4 5 5> tmp <- rle(id) > tmpRun Length Encoding lengths: int [1:12] 2 3 1 4 1 3 2 3 1 1 ... values : num [1:12] 1 2 3 4 1 2 3 1 2 3 ...> rep( seq_along(tmp$lengths), tmp$lengths )[1] 1 1 2 2 2 3 4 4 4 4 5 6 6 6 7 7 8 8 8 9 10 11 11 11 12 [26] 12 -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Lisa > Sent: Wednesday, December 02, 2009 1:30 PM > To: r-help at r-project.org > Subject: [R] Ordering numbers > > > Hello all, > > I have a set of numbers that looks like this: > > > id <- c(1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 1, 2, 2, 2, 3, 3, 1, 1, 1, 2, > 3, 4, > > 4, 4, 5, 5) > > id > [1] 1 1 2 2 2 3 4 4 4 4 1 2 2 2 3 3 1 1 1 2 3 4 4 4 5 5 > > Please ignore the bold numbers, I just want to make my problem clear. > I am going to order them as this: > > 1 1 2 2 2 3 4 4 4 4 5 6 6 6 7 7 8 8 8 9 10 11 11 11 12 12 > > Can anyone please help how to get this done? Your help would be greatly > appreciated. > > Lisa > > -- > View this message in context: http://n4.nabble.com/Ordering-numbers- > tp941453p941453.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
Your output does not match the requested output, I think the original poster may have used the word "order" differently than how you are thinking. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Senthil Kumar M > Sent: Wednesday, December 02, 2009 1:36 PM > To: Lisa > Cc: r-help at r-project.org > Subject: Re: [R] Ordering numbers > > On Wed, Dec 2, 2009 at 3:30 PM, Lisa <lisajca at gmail.com> wrote: > > > > Hello all, > > > > I have a set of numbers that looks like this: > > > >> id <- c(1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 1, 2, 2, 2, 3, 3, 1, 1, 1, 2, > 3, 4, > >> 4, 4, 5, 5) > >> id > > [1] 1 1 2 2 2 3 4 4 4 4 1 2 2 2 3 3 1 1 1 2 3 4 4 4 5 5 > > > > Please ignore the bold numbers, I just want to make my problem clear. > > I am going to order them as this: > > > > 1 1 2 2 2 3 4 4 4 4 5 6 6 6 7 7 8 8 8 9 10 11 11 11 12 12 > > > > Can anyone please help how to get this done? Your help would be > greatly > > appreciated. > > > > Lisa > > > > Hi, > > ?sort > > > sort(id) > [1] 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 4 4 4 4 4 4 4 5 5 > > Senthil > > ______________________________________________ > 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.
> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Lisa > Sent: Wednesday, December 02, 2009 12:30 PM > To: r-help at r-project.org > Subject: [R] Ordering numbers > > > Hello all, > > I have a set of numbers that looks like this: > > > id <- c(1, 1, 2, 2, 2, 3, 4, 4, 4, 4, 1, 2, 2, 2, 3, 3, 1, > 1, 1, 2, 3, 4, > > 4, 4, 5, 5) > > id > [1] 1 1 2 2 2 3 4 4 4 4 1 2 2 2 3 3 1 1 1 2 3 4 4 4 5 5 > > Please ignore the bold numbers, I just want to make my problem clear. > I am going to order them as this: > > 1 1 2 2 2 3 4 4 4 4 5 6 6 6 7 7 8 8 8 9 10 11 11 11 12 12Do you want to assign a run identification number to each value? If so try > c(1,cumsum(id[-1]!=id[-length(id)])+1) [1] 1 1 2 2 2 3 4 4 4 4 5 6 6 6 7 7 8 8 8 9 10 11 11 11 12 12 or the equivalent > r<-rle(id) > rep(seq_along(r$lengths), r$lengths) [1] 1 1 2 2 2 3 4 4 4 4 5 6 6 6 7 7 8 8 8 9 10 11 11 11 12 12 (cumsum(x[-1]!=x[-length(x)] is part of the rle algorithm.) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com> Can anyone please help how to get this done? Your help would > be greatly > appreciated. > > Lisa > > -- > View this message in context: > http://n4.nabble.com/Ordering-numbers-tp941453p941453.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >
Windows XP R 2.10 I am unable to start R. When I try to launch R, I receive a text box stating: Fatal error: unable to restore saved data in .RData I tried reloading R (version 2.10), and restarted my computer . . . I still have the problem. HELP! John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}}
Corrupted datasets have been a fairly commonly observed cause of such problems. Correction is through deletion (or removal to a different directory if you want to check without committing to that solution) of the offending .Rdata file. -- David, On Dec 2, 2009, at 4:27 PM, John Sorkin wrote:> Windows XP > R 2.10 > > I am unable to start R. When I try to launch R, I receive a text box > stating: > > Fatal error: unable to restore saved data in .RData > > > I tried reloading R (version 2.10), and restarted my computer . . . > I still have the problem. > > HELP! > > John > > > > John David Sorkin M.D., Ph.D. > Chief, Biostatistics and Informatics > University of Maryland School of Medicine Division of Gerontology > Baltimore VA Medical Center > 10 North Greene Street > GRECC (BT/18/GR) > Baltimore, MD 21201-1524 > (Phone) 410-605-7119 > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > Confidentiality Statement: > This email message, including any attachments, is for th...{{dropped: > 6}} > > ______________________________________________ > 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.David Winsemius, MD Heritage Laboratories West Hartford, CT