Convert values of an Object to Logical Vector in R Programming - as.logical() Function Last Updated : 08 Nov, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 logical vector # Creating a vector x <- c(1, 2, 3, 0, 1.4, NA) # Calling as.logical() function as.logical(T) as.logical("F") as.logical(2) as.logical(x) Output: [1] TRUE [1] FALSE [1] TRUE [1] TRUE TRUE TRUE FALSE TRUE NAExample 2: Multiple objects with as.logical() Function in R. R # R Program to convert # an object to logical vector # Creating matrix x1 <- matrix(c(1:4), 2, 2) x2 <- matrix(c(2, 0, 1, 1.3), 2, 2) # Calling as.logical() function as.logical(x1) as.logical(x2) Output: [1] TRUE TRUE TRUE TRUE [1] TRUE FALSE TRUE TRUE Comment More infoAdvertise with us Next Article Check whether a value is logical or not in R Programming - is.logical() Function N nidhi_biet Follow Improve Article Tags : R Language R DataFrame-Function R Vector-Function R Object-Function R Matrix-Function R Array-Functions R List-Function +3 More 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 Object to List in R Programming - as.list() Function as.list() function in R Programming Language is used to convert an object to a list. These objects can be Vectors, Matrices, Factors, and dataframes. Syntax: as.list(object) Parameters: object: Vector, Matrix, factor, or data frame R - as.list() Function ExampleExample 1: Converting Vector to list 2 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 Convert an Object to a Table in R Programming - as.table() Function as.table() function in R Language is used to convert an object into a table. Syntax: as.table(x) Parameters: x: Object to be converted Example 1: Python3 1== # R Program to convert # an object to a table # Creating a vector vec = c(2, 4, 3, 1, 2, 3, 2, 1, 4, 2) # Calling as.table() Function as.table 1 min read Return True Indices of a Logical Object in R Programming - which() Function 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 w 1 min read Check if values in a vector are True or not in R Programming - all() and any() Function In this article, we are going to check if the values in a vector are true or not in R Programming Language. R - all() function all() function in R Language will check in a vector whether all the values are true or not. Syntax: all(x, na.rm) Parameters: x: vectorna.rm: logical, if NA value to remov 2 min read Like