Question: I am unable to make a POST method request with . I am unable to send a request object with it. 

For example see [this example](https://stackoverflow.com/a/43552582). Here only GET request is being made. But I want to make a POST request.

Answer: 
Using the data shown reproducibly in the Note at the end, form the vector of cutpoints (i.e. the first number in each interval) and then use `findInterval` to find the interval corresponding to the weight.

```
cutpoints <- as.numeric(sub("-.*", "", dfprice$wgt_intvl))
transform(dfmain, price = dfprice$price[findInterval(wgt, cutpoints)])

```

giving:

```
  Order wgt price
1    01  22    75
2    02   5    50
3    03  35   135
4    04  25   135

```

Note
----

```
dfmain <- data.frame(Order = c("01", "02", "03", "04"), wgt = c(22, 5, 35, 25), 
 stringsAsFactors = FALSE)

dfprice <- data.frame(wgt_intvl = c("0-15", "15-25", "25-50"), 
 price = c(50, 75, 135), stringsAsFactors = FALSE)

```
Instead of an if-statement you could use a more efficient case\_when operation:

```
library(dplyr)
 df %>%
mutate(cost = case_when(
    wgt < 15 ~ 50,
    wgt > 15 & wgt <25 ~ 75,
    TRUE ~ 135))

```

Alternatively you could use `cut()` to transform wgt to wgt\_intvl and match via `left_join()`.