The is.unsorted() function in R is used to check if a given object passed to it is not sorted. It returns TRUE if the object is not sorted and FALSE if otherwise.
is.unsorted(x, na.rm = FALSE, strictly = FALSE)
The is.unsorted() function takes the following parameter values:
x: This is any R object of numerical values.na.rm: This takes the logical value (TRUE or FALSE) indicating whether the missing values be removed before checking or not.strictly: This takes the logical value (TRUE or FALSE) indicating whether the check should be strictly increasing values or not.The is.unsorted() function returns a length-one logical value.
# creating R objectsa <- c( 1:10, 12:15, 20)b <- w <- c(12:15, 1:10, 20)# printing the R objectsab# Checking if the objects are unsortedis.unsorted(a)is.unsorted(b)
a and b, containing numerical values.a and b.is.unsorted() function. We print the results to the console.