[R] indexing a vector
Ross Ihaka
ihaka at stat.auckland.ac.nz
Thu Oct 2 21:41:39 CEST 2003
morozov wrote:
>>x<-rnorm(100)
>>MyLevels<-quantile(x,probs=c(0,.5,1))
>>MyLevels
>
> 0% 50% 100%
> -2.11978442 -0.03770613 2.00186397
>
> next i want to replace each x[i] in x by 1,2,3 or 4 depending on which
> quantile that x[i] falls. How do I do that in a "vector" fashion?
Take a look at the "cut" function.
--
Ross Ihaka Email: ihaka at stat.auckland.ac.nz
Department of Statistics Phone: (64-9) 373-7599 x 85054
University of Auckland Fax: (64-9) 373-7018
Private Bag 92019, Auckland
New Zealand
More information about the R-help
mailing list