R: Is cut the right function to do this? -


i'm struggling cut...i don't know if there's function this.

i have big table values , matrix or vector thresholds.

let's have matrix containing thresholds 0.6, 0.8, 1.0, 1.2, 1.4 want find out value (i.e. 0.9) in sector value falls. it's "grading" system. value <= 0.6 gets 5, <= 0.8 , > 0.6 gets 4 etc. want write value (5, 4, 3 etc.) resulting table.

ok here's code have far:

cut(1.2, breaks=c(0.6,0.8,1.0,1.2,1.4), labels(5,4,3,2,1)) 

but doesn't work yet..with labels don't know how many have insert there since error lenghts of vectors different. without labels parameter still don't work correctly. still outputs different segments , not 1 value in guess...

cut should correct function, you're doing things wrong.

first, there typos in code. labels = c(...) correct version.

second, think you're doing: creating intervals. how many? try cut without labels see:

cut(1.2, breaks=c(0.6,0.8,1.0,1.2,1.4)) # [1] (1,1.2] # levels: (0.6,0.8] (0.8,1] (1,1.2] (1.2,1.4] 

there 4 levels created way you're doing it, need provide 4 labels (or redefine break points).


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -