Moderat
Moderat

Reputation: 1560

How to get values in a data range in R

I have a table that goes as follows:

Zip Code ApprovalRate ...

75229 0.32 ...

I split my approval rate by quantiles, so discounting the zip codes with approval rate 0 or 100%, the breaks are 0.0303 0.3333 0.4394 0.5060 0.6190 0.9524 which I am naming Very Low, Low, Med, High, Very High

Now I would like to make a new vector of lowZip which are the zip codes for which the approval rate falls into the Low range of 0.0303 - 0.3333

I have tried something like

idxLow = which(0.0303 <= Approval & Approval <= 0.333)

and then

zipLow = mydata[idxLow, 1]

But I have to think there is a better way.

Upvotes: 0

Views: 94

Answers (1)

Se&#241;or O
Se&#241;or O

Reputation: 17412

Just:

 mydata[0.0303 <= Approval & Approval <= 0.333, 1]

Should work.

Upvotes: 2

Related Questions