Check if values in a vector are True or not in R Programming - all() and any() Function Last Updated : 23 Dec, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 removed before result Example 1: Basic example of all() function in r R # R program to illustrate # all function # Example vector <x1 <- c(1, 2, 3, - 4, 5) all(x1 < 0) Output: FALSE Here in the above code, we have created an example vector and applied all() functions to it. Clearly, all the values are not less than zero, one value -4 is less than zero, so the answer is FALSE. Example 2: Using na.rm argument R # R program to illustrate # all function with na.rm # Example vector with NA value x2 <- c(1, 2, 3, -4, 5, NA) # Apply all function with na.rm = TRUE all(x2 < - 10, na.rm = TRUE) Output: TRUE Here in the above code, we set the value of na.rm to TRUE. So the output is TRUE. As all of them are greater than -10 in the above code. R - any() function any() function in R Programming language will check in vector whether any of the values is true. Syntax: any(x, na.rm) Parameters: x: vector na.rm: logical, if NA value to removed before result Example 1: any() function R # R program to illustrate # any() function # Example vector x1 <- c(1, 2, 3, - 4, 5, ) # Apply any function in R any(x1 < 0) Output: TRUE Here in the above code, we have applied any() function. Since one value is "-4" (lesser than 0), so the answer is TRUE. Example 2: Any function using na.rn argument R # R program to illustrate # any function with na.rm # Example vector with NA value x2 <- c(1, 2, 3, -4, 5, NA) # Apply any function with na.rm = TRUE any(x2 < - 10, na.rm = TRUE) Output: FALSE Here in the above code, we set the value of na.rm to TRUE. So the output is False. As all of them are lesser than -10 in the above code. Comment More infoAdvertise with us Next Article Convert values of an Object to Logical Vector in R Programming - as.logical() Function A akhilsharma870 Follow Improve Article Tags : R Language Similar Reads 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 if an Object is a Table in R Programming - is.table() Function is.table() function in R Language is used to check if an object is a table. Syntax: is.table(x) Parameters: x: Object to be checked Example 1: Python3 1== # R Program to check # if an object is a table # Creating a vector vec = c(2, 4, 3, 1, 2, 3, 2, 1, 4, 2) # calling is.table() Function is.table(v 1 min read Check if a value or a logical expression is TRUE in R Programming - isTRUE() Function isTRUE() function in R Language is used to check whether a value or a logical expression is true or not. Syntax: isTRUE(x) Parameters: x: logical or number-like vector Example 1: Python3 1== # R Program to test whether # an expression is TRUE # Calling isTRUE() Function isTRUE(1) isTRUE(1>0) isTR 1 min read Check if Elements of a Vector are non-empty Strings in R Programming - nzchar() Function nzchar() function in R Language is used to test whether elements of a character vector are non-empty strings. Syntax: nzchar(x) Parameters: x: character vector Example 1: Python3 # R program to illustrate # nzchar function # Initializing a character vector x <- c("GFG", "gfg") 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 Check if the elements of a Vector are Finite, Infinite or NaN values in R Programming - is.finite(), is.infinite() and is.nan() Function is.finite() function in R Language is used to check if the elements of a vector are Finite values or not. It returns a boolean value for all the elements of the vector. Syntax: is.finite(x) Parameters: x: Vector to be checked Example: Python3 1== # R program to illustrate # the use of is.finite() fu 2 min read Like