[R] Add number series to data frame

syrvn mentor_ at gmx.net
Tue Mar 6 17:47:57 CET 2012


Hi,

Is there a simple way of doing the following in R?


a <- data.frame(name = c(rep("A", 3), rep("B", 5), rep("C", 10)))

> a
   name
1     A
2     A
3     A
4     B
5     B
6     B
7     B
8     B
9     C
10    C
11    C
12    C
13    C
14    C
15    C
16    C
17    C
18    C

Do some fancy R code here:

> a
   name val
1     A  1
2     A  2
3     A  3
4     B  1
5     B  2
6     B  3
7     B  4
8     B  5
9     C  1
10    C  2
11    C  3
12    C  4
13    C  5
14    C  6
15    C  7
16    C  8
17    C  9
18    C  10



--
View this message in context: http://r.789695.n4.nabble.com/Add-number-series-to-data-frame-tp4450495p4450495.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list