Hi, Try: set.seed(89) ?dat1 <- within(data.frame(column1=LETTERS[1:5],column2=rnorm(5)),order1 <- order(order(column2))+32) ?within(dat1,order2 <- order(order(dat1$order1))) ?column1??? column2 order1 order2 1?????? A -1.4516020???? 33????? 1 2?????? B? 0.7081001???? 35????? 3 3?????? C? 1.5930974???? 36????? 4 4?????? D -0.8375955???? 34????? 2 5?????? E? 1.9294701???? 37????? 5 #or (dat1$order1-33)+1 #[1] 1 3 4 2 5 A.K. Hi, I have data with a column that is the order of my data, it starts with 33 and goes on but not one by one, for example like this: column1 ? ? ? ? column2 ? ? ? order ? ? ? ? ? ? ? ? ? ??. ? ? ? ? ? ? ? 33 .. ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ?36 ? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ?45 ? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? .. I want to make 33 equals to 1, and then it calculates for other numbers, like 36 be 4 and so on. Is there a way to do thins in R? Thank you so much
Renumber series
2 messages · arun, Bert Gunter
??? What's wrong with simply order - 32 ?? -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." H. Gilbert Welch
On Tue, Feb 4, 2014 at 2:37 PM, arun <smartpink111 at yahoo.com> wrote:
Hi, Try: set.seed(89) dat1 <- within(data.frame(column1=LETTERS[1:5],column2=rnorm(5)),order1 <- order(order(column2))+32) within(dat1,order2 <- order(order(dat1$order1))) column1 column2 order1 order2 1 A -1.4516020 33 1 2 B 0.7081001 35 3 3 C 1.5930974 36 4 4 D -0.8375955 34 2 5 E 1.9294701 37 5 #or (dat1$order1-33)+1 #[1] 1 3 4 2 5 A.K. Hi, I have data with a column that is the order of my data, it starts with 33 and goes on but not one by one, for example like this: column1 column2 order ? ?. 33 .. ? 36 ? ? 45 ? ? .. I want to make 33 equals to 1, and then it calculates for other numbers, like 36 be 4 and so on. Is there a way to do thins in R? Thank you so much
______________________________________________ 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.