Big_Data_Slip_5

Slip No.5

1) Write an R program to find Sum, Mean and Product of a Vector.

    # Define the vector
    vector <- c(12, 45, 3, 67, 23, 89, 5)

    # Calculate the sum of the vector
    sum_vector <- sum(vector)

    # Calculate the mean of the vector
    mean_vector <- mean(vector)

    # Calculate the product of the vector
    product_vector <- prod(vector)

    # Print the results
    cat("The sum of the vector is:", sum_vector, "\n")
    cat("The mean of the vector is:", mean_vector, "\n")
    cat("The product of the vector is:", product_vector, "\n")

No comments:

Post a Comment