Q:

Write a R program to test whether a given vector contains a specified element

0

Write a R program to test whether a given vector contains a specified element.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

x = c(10, 20, 30, 25, 9, 26)
print("Original Vectors:")
print(x)
print("Test whether above vector contains 25:")
print(is.element(25, x))
print("Test whether above vector contains 56:")
print(is.element(56, x))

Sample Output:

[1] "Original Vectors:"
[1] 10 20 30 25  9 26
[1] "Test whether above vector contains 25:"
[1] TRUE
[1] "Test whether above vector contains 56:"
[1] FALSE

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now