R Program to test if value of an element in a vector is greater than 25

How to test whether the elements of a given vector greater than 25 or not

Here we are explaining how to write an R program to test whether the elements of a given vector are greater than 25 or not. Here we are using the operator ' > ' for this finding. Checks if each element of the first vector is greater than the corresponding element of the second vector and returns the boolean value TRUE or FALSE. This operator is called a relational operator.

 

How to test whether the elements of a given vector greater than 25 or not in the R program

Below are the steps used in the R program to test whether the elements of a given vector are greater than 25. In this R program, we directly give the values to compare. Here using the relational operator each value of the vector is compared to check whether it is greater than the given value. The variable A is assigned with vector values. And the checking is done as like (A> 25).

ALGORITHM

STEP 1: Assign variable A with vector values

STEP 2: First print original vector values

STEP 3: check the vector values are greater than 25 as (A> 25)

STEP 4: print TRUE or FALSE as per comparison

R Source Code

                                          A= c(27,26,9,7,10,0,14,30)
print("Original vector is:")
print(A)
print("Test whether the value > 25 or not:")
print(A> 25)
                                      

OUTPUT

[1] "Original vector is:"
[1] 27  26  9  7  10  0  14  30
[1] "Test whether the value > 25 or not:"
[1]  TRUE  TRUE  FALSE  FALSE  FALSE  FALSE  FALSE  TRUE