Write a R program to find Sum, Mean and Product of a Vector, ignore element like NA or NaN.
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
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer