[R] Classifying values in vector

From: mark salsburg <mark.salsburg_at_gmail.com>
Date: Thu 18 Aug 2005 - 02:48:21 EST


I have a vector of size 217 called "A".

the values of A are not sorted and range from 0 to 1 (normalized)

I am having difficulty writing a program to create a new vector "B" where

if A's value is 0< A <=0.333 then B is 0
if A's value is 0.333< A <=0.666 then B is 1
if A's value is 0.666< A <=1 then B is 2

so if A is

0.22
0.999
0.444

0

B would be

0
2
1
0

thank you,



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Aug 18 03:07:03 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:50 EST