Here we are explaining how to write an R program to divide two vectors. We can give two vector values to calculate the division. For the calculation of vector division here we use the division(/) operator.
Given below are the steps which are used in the R program to divide two vectors. In this R program, we accept the vector values into variables A and B. The result value of vectors is assigned variable C.Finally the variable C is printed as output vector.
A = c(10, 20, 30)
B = c(20, 10, 40)
print("Original Vectors are:")
## [1] "Original Vectors are:"
print(A)
## [1] 10 20 30
print(B)
## [1] 20 10 40
print("After dividing Vectors:")
## [1] "After dividing Vectors:"
C = A / B
print(C)
## [1] 0.50 2.00 0.75
A = c(15, 25, 35)
B = c(25, 15, 45)
print("Original Vectors are:")
## [1] "Original Vectors are:"
print(A)
## [1] 15 25 35
print(B)
## [1] 25 15 45
print("After dividing Vectors:")
## [1] "After dividing Vectors:"
C = A / B
print(C)
## [1] 0.6000000 1.6666667 0.7777778