Return True Indices of a Logical Object in R Programming - which() Function Last Updated : 08 Jun, 2020 Comments Improve Suggest changes Like Article Like Report which() function in R Language is used to return the indices of the object which return true for the logical operation passed as argument. Syntax: which(x, arr.ind) Parameters: x: logical object arr.ind: Boolean value to display indices Example 1: Python3 1== # R program to illustrate # the use of which() function # Create a matrix x <- matrix(1:9, 3, 3) x # Calling which() function which(x %% 2 == 0, arr.ind = TRUE) Output: [, 1] [, 2] [, 3] [1, ] 1 4 7 [2, ] 2 5 8 [3, ] 3 6 9 row col [1, ] 2 1 [2, ] 1 2 [3, ] 3 2 [4, ] 2 3 Here, in the above code, the which() function returns the indices of all the even numbers present in the matrix. Example 2: Python3 1== # R program to illustrate # the use of which() function # Using predefined dataset BOD # Calling which() function which(BOD$demand == 19, arr.ind = TRUE) Output: Time demand 1 1 8.3 2 2 10.3 3 3 19.0 4 4 16.0 5 5 15.6 6 7 19.8 [1] 3 Comment More infoAdvertise with us Next Article Return True Indices of a Logical Object in R Programming - which() Function N nidhi_biet Follow Improve Article Tags : R Language R Vector-Function R Object-Function R Matrix-Function R Array-Functions +1 More Similar Reads Display the internal Structure of an Object in R Programming - str() Function str() function in R Language is used for compactly displaying the internal structure of a R object. It can display even the internal structure of large lists which are nested. It provides one liner output for the basic R objects letting the user know about the object and its constituents. It can be 3 min read Convert values of an Object to Logical Vector in R Programming - as.logical() Function as.logical() function in R Language is used to convert an object to a logical vector. Syntax: as.logical(x)Parameters:Â x: Numeric or character object R - as.logical() Function ExampleExample 1: Basic example of as.logical() Function in R Programming Language.R # R Program to convert # an object to l 1 min read Check whether a value is logical or not in R Programming - is.logical() Function is.logical() function in R Language is used to check whether a value is logical or not. Syntax: is.logical(x) Parameters: x: Value to be checked Example 1: Python3 1== # R Program to test whether # a value is logical or not # Calling is.logical() function is.logical(0) is.logical(!5) is.logical(T) i 1 min read Return an Object with the specified name in R Programming - get0() and mget() Function In R programming, get0() and mget() function works similar to get() function. It is used to search and return the object with the specified name passed to it as argument. get0() Function get0() function has the same syntax as get() function but there is an addition of a new parameter which returns a 2 min read Search and Return an Object with the specified name in R Programming - get() Function get() function in R Language is used to return an object with the name specified as argument to the function. This is another method of printing values of the objects just like print function. This function can also be used to copy one object to another. Syntax: get(object) Parameters: object: Vecto 1 min read Return the Index of the First Maximum Value of a Numeric Vector in R Programming - which.max() Function which.max() function in R Language is used to return the location of the first maximum value in the Numeric Vector. Syntax: which.max(x) Parameters: x: Numeric Vector Example 1: Python3 1== # R program to find index of # first maximum value # Creating a vector x <- c(2, 3, 4, 5, 1, 2, 3, 1, 2) # 1 min read Return the Index of the First Minimum Value of a Numeric Vector in R Programming - which.min() Function which.min() function in R Language is used to return the location of the first minimum value in the Numeric Vector. Syntax: which.min(x) Parameters: x: Numeric Vector Example 1: Python3 1== # R program to find index of # first minimum value # Creating a vector x <- c(2, 3, 4, 5, 1, 2, 3, 1, 2) # 1 min read Sort elements of an Object by its Index Values in R Programming - order() function order() function in R Language is used to sort an object by its index value. These objects can be vector, matrix or data frames. This function accepts boolean value as argument to sort in ascending or descending order. Syntax: order(x, decreasing, na.last) Parameters: x: Vector to be sorted decreasi 1 min read Check if the Object is a List in R Programming - is.list() Function is.list() function in R Language is used to return TRUE if the specified data is in the form of list, else returns FALSE. Syntax: is.list(X) Parameters: x: different types of data storage Example 1: Python3 # R program to illustrate # is.list function # Initializing some list a <- list(1, 2, 3) b 1 min read Like