cal Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Luana Marotta
> Sent: Wednesday, December 01, 2010 9:08 AM
> To: r-help; r-help-request
> S
Luana -
It's probably not the most efficient way, but here's
a solution that's not dependent on the grades being sorted:
grade <- c(4,4,4,5,5,7,7,7,7,8,8,8,9,9,9,9,9,10,10,10)
unlist(sapply(rle(grade)$lengths,function(x)seq(1,x)))
[1] 1 2 3 1 2 1 2 3 4 1 2 3 1 2 3 4 5 1 2 3
Hi Luana,
Try this:
ID <- 1:20
grade <- c(4, 4, 4, 5, 5, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10)
d <- data.frame(ID, grade)
d$Sequence <- do.call(c, sapply(rle(grade)$lengths, seq))
d
HTH,
Jorge
On Wed, Dec 1, 2010 at 11:08 AM, Luana Marotta <> wrote:
> Hello fellows,
>
> I would like
the thing itself have purpose? Or do we, what's the word... imbue it."
- Jubal Early, Firefly
r-help-boun...@r-project.org wrote on 12/01/2010 11:08:06 AM:
> [image removed]
>
> [R] Sequence for repeated numbers
>
> Luana Marotta
>
> to:
>
> r-hel
Hello fellows,
I would like to create a sequence for repeated numbers in a dataset. For
example:
ID <- c(1:20)
grade <- c(4,4,4,5,5,7,7,7,7,8,8,8,9,9,9,9,9,10,10,10)
Data:
ID Grade
1 4
2 4
3 4
4 5
5 5
6 7
7 7
8 7
9 7
(...)
I would like to create a variable "sequence":
Data:
5 matches
Mail list logo