Q:

Write a R program to count the specific value in a given vector

0

Write a R program to count the specific value in a given vector.

All Answers

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

x = c(10, 20, 30, 20, 20, 25, 9, 26)
print("Original Vectors:")
print(x)
print("Count specific value(20) in above vector:")
print(sum(x==20))

Sample Output:

[1] "Original Vectors:"
[1] 10 20 30 20 20 25  9 26
[1] "Count specific value(20) in above vector:"
[1] 3

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