Binning a Numeric Vector in R Programming - .bincode() Function Last Updated : 19 Jun, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report .bincode() function in R Language is used to bin a numeric vector and return integer codes for the binning. Syntax: .bincode(x, breaks, right = TRUE, include.lowest = FALSE) Parameters: x: a numeric vector which is to be converted to integer codes by binning. breaks: a numeric vector of two or more cut points, sorted in increasing order. right: logical value, indicating if the intervals should be closed on the right (and open on the left) or vice versa. include.lowest: logical value, indicating if an ‘x[i]’ equal to the lowest (or highest, for right = FALSE) ‘breaks’ value should be included in the first (or last) bin. Example 1: Python3 # R program to illustrate # .bincode function # Initializing a numeric vector which is # to be converted to integer # codes by binning x <- c(0, 0.01, 0.5, 0.99, 1) # a numeric vector of two or more cut # points, sorted in increasing order b <- c(0, 1, 2, 3) # Calling .bincode() function .bincode(x, b) .bincode(x, b, TRUE) .bincode(x, b, FALSE) Output: [1] NA 1 1 1 1 [1] NA 1 1 1 1 [1] 1 1 1 1 2 Example 2: Python3 # R program to illustrate # .bincode function # Initializing a numeric vector which is # to be converted to integer # codes by binning x <- c(0, 0.1, 0.2, 0.3, 1) # a numeric vector of two or more cut # points, sorted in increasing order b <- c(0, 1, 2, 3) # Calling .bincode() function .bincode(x, b, TRUE, TRUE) .bincode(x, b, FALSE, TRUE) Output: [1] 1 1 1 1 1 [1] 1 1 1 1 2 Comment More infoAdvertise with us Next Article Calculate Median of elements of a Vector in R Programming - median() Function K Kanchan_Ray Follow Improve Article Tags : R Language R Vector-Function Similar Reads Convert an Object into a Vector in R Programming - as.vector() Function as.vector() function in R Language is used to convert an object into a vector. Syntax: as.vector(x) Parameters: x: Object to be converted Example 1: Python3 1== # R program to convert an object to vector # Creating an array x <- array(c(2, 3, 4, 7, 2, 5), c(3, 2)) x # Calling as.vector() Function 1 min read Convert an Integer to Bits in R Programming - intToBits() Function intToBits() function in R Language is used to convert an integer into Bits i.e. 0s and 1s. The output is of length 32 times the length of integer vector. Syntax: intToBits(x) Parameters: x: Integer or integer vector Example 1: Python3 1== # R program to convert an integer to bits # Calling the intTo 2 min read Convert a Vector into Factor in R Programming - as.factor() Function as.factor() function in R Programming Language is used to convert the passed object(usually Vector) into a Factor. Syntax: as.factor(object) Parameters: Object: Vector to be convertedas.factor() Function in R ExampleExample 1: Convert a Factor in RR # Creating a vector x<-c("female", "male", "ma 1 min read Compute the Negative Binomial Density in R Programming - dnbinom() Function dnbinom() function in R Language is used to compute the value of negative binomial density. It also creates a plot of the negative binomial density. Syntax: dnbinom(vec, size, prob) Parameters: vec: x-values for binomial density size: Number of trials prob: Probability Example 1: Python3 1== # R pro 1 min read Calculate Median of elements of a Vector in R Programming - median() Function median() function in R Language is used to calculate the median of the elements of the numeric vector passed as argument. Syntax: median(x, na.rm) Parameters: x: Numeric Vector na.rm: Boolean value to ignore NA Example 1: Python3 1== # R program to calculate median of a vector # Creating vector x1 1 min read Append Operation on Vectors in R Programming In this article, let us discuss different methods to concatenate/append values to a vector in R Programming Language. Append method in RVectors in the R Programming Language is a basic objects consisting of sequences of homogeneous elements. vector can be integer, logical, double, character, comple 2 min read Like