Hi Petr,
that works great. thanks!
I was working my head off on that :)
--
View this message in context:
http://r.789695.n4.nabble.com/Add-number-series-to-data-frame-tp4450495p4452962.html
Sent from the R help mailing list archive at Nabble.com.
__
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
10C
11C
12C
13C
14C
15C
16C
17C
18C
Do some fancy R code
Here's one possible approach. It assumes that a$name is a factor, as
it is in your example, but does not require that each sequence has a
unique value (see second example).
a - data.frame(name = c(rep(A, 3), rep(B, 5), rep(C, 10)))
data.frame(name=a,
I'd just sort them first, if you want consecutive numbers for each
value. (It would have been nice to specify that in the original
question.)
If you need for some reason to put them back in order, you can always
cbind(1:nrow(x), x) before sorting, to get an index to sort on after
you're done.
As
Hi Sarah,
thanks a lot for this peace of code.
Is it possible to give the second sequence of B in your second example
(data frame b)
the numbers 6, 7 and 8 instead of 1, 2 and 3 again? In my real data I have
more columns than
only those two and sometimes the are sorted differently so that
On Tue, Mar 06, 2012 at 09:32:37AM -0800, syrvn wrote:
Hi Sarah,
thanks a lot for this peace of code.
Is it possible to give the second sequence of B in your second example
(data frame b)
the numbers 6, 7 and 8 instead of 1, 2 and 3 again? In my real data I have
more columns than
only
6 matches
Mail list logo