HI,
May be this also works:
plot(x,col=as.numeric(factor(x)))
A.K.
- Original Message -
From: Rui Barradas
To: Suparna Mitra
Cc: r-help@r-project.org
Sent: Friday, June 21, 2013 11:32 AM
Subject: Re: [R] How to define desired numbers to a vector based on the
present numbers
Hello
Yes I have already changed that as this was only a small vector, my real
vector is quite big..
thanks a ton.
Bets wishes,
Mitra
On 21 June 2013 23:43, Clint Bowman wrote:
> I suspect the OP may want
>
> rep(1:length(unique(x)), rle(x[order(x)])$lengths)[**order(order(x))]
>
> to allow for vari
I suspect the OP may want
rep(1:length(unique(x)), rle(x[order(x)])$lengths)[order(order(x))]
to allow for variable numbers of unique values.
Clint
Clint BowmanINTERNET: cl...@ecy.wa.gov
Air Quality Modeler INTERNET: cl...@math.utah.edu
Department of
Thanks a lot Rui,
It helps :)
I can modify this according to my need.. I didn't know about rle function.
Thanks again,
Mitra
On 21 June 2013 23:32, Rui Barradas wrote:
> Hello,
>
> I'm not sure I understand. You want to attribute a color number 1:7 to
> each element of your vector? Maybe the fo
Hello,
I'm not sure I understand. You want to attribute a color number 1:7 to
each element of your vector? Maybe the following will do.
x <- scan(text = "
43 43 43 43 0 39 13 39 50 39 39 23 23 32 0 13 32 23 32 23 0 13 13 0
")
cols <- rep(1:7, rle(x[order(x)])$lengths)[order(order(x))]
pl
Hello R experts,
I want to define desired numbers to a vector based on the present
numbers. Can anybody please help me?
Obviously I found worst ways to do it, but I believe there must be any
better way.
I have vector as
> X
[1] 43 43 43 43 0 39 13 39 50 39 39 23 23 32 0 13 32 23 32 23 0 13
6 matches
Mail list logo