[R] Renumber series
arun
smartpink111 at yahoo.com
Tue Feb 4 23:37:38 CET 2014
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
More information about the R-help
mailing list