R>findInterval(4.5, c(1,2,4,5,6))
[1] 3
will do that with price-is-right matching (closest without going over).
More Related Contents:
- How to change formats of multiple variables in one dataset?
- Filtering a data frame on a vector [duplicate]
- Replace / translate characters in a string
- using Unicode ‘dingbat-like’ glyphs in R graphics, across devices & platforms, especially PDF
- Programming with dplyr using string as input
- Select subset of columns in data.table R [duplicate]
- Addressing x and y in aes by variable number
- How to rename a single column in a data.frame?
- how to read data in utf-8 format in R?
- Dynamically build call for lookup multiple columns
- Center x and y axis with ggplot2
- Categorize numeric variable with mutate
- Exact number of bins in Histogram in R
- Which is the best method to apply a script repetitively to n .csv files in R?
- Split a string by any number of spaces
- Use rle to group by runs when using dplyr
- Outputting multiple lines of text with renderText() in R shiny
- dplyr: lead() and lag() wrong when used with group_by()
- Imported a csv-dataset to R but the values becomes factors
- Why (or when) is Rscript (or littler) better than R CMD BATCH?
- How do I tell the R interpreter how to use the proxy server?
- Replace -inf, NaN and NA values with zero in a dataset in R
- Specifying formula in R with glm without explicit declaration of each covariate
- Equivalent to rowMeans() for min()
- How to cross-paste all combinations of two vectors (each-to-each)?
- how do you order Months in ggplot
- Collapse all columns by an ID column [duplicate]
- Add data to ggvis tooltip that’s contained in the input dataset but not directly in the vis
- Error in Confusion Matrix : the data and reference factors must have the same number of levels
- Add number of observations per group in boxplot