Q:

Write a R program to find Sum, Mean and Product of a Vector, ignore element like NA or NaN

0

Write a R program to find Sum, Mean and Product of a Vector, ignore element like NA or NaN.

All Answers

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

x = c(10, NULL, 20, 30, NA)
print("Sum:")
#ignore NA and NaN values
print(sum(x, na.rm=TRUE))
print("Mean:")
print(mean(x, na.rm=TRUE))  
print("Product:")
print(prod(x, na.rm=TRUE))

Sample Output:

[1] "Sum:"
[1] 60
[1] "Mean:"
[1] 20
[1] "Product:"
[1] 6000

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