Skip to content
Prev 310390 / 398506 Next

if between 500-600 give 550

On Nov 9, 2012, at 5:10 AM, Tagmarie wrote:

            
findInterval(myframe$Hunger, c(300, 400, 500, 600) ) ]
ID Hunger grpH
1  2    415  450
2  3    452  450
3  4    550  550
4  5    318  350

Please note that your specification had overlapping intervals and that 'findInterval' by default uses closed intervals on the left and open intervals on the right. (This is the opposite of the default behavior of cut(). ) So I suppose you could say R's implementations are just as ambiguous as your problem specification.
ID Hunger grpH grpHc
1  2    415  450   450
2  3    452  450   450
3  4    550  550   550
4  5    318  350   350

Note also that cut returns a factor:
$ID
[1] "numeric"

$Hunger
[1] "numeric"

$grpH
[1] "numeric"

$grpHc
[1] "factor"