Sunday, 29 October 2023

Write an R program to create three vectors a,b,c with 3 integers. Combine the three vectors to become a 3×3 matrix where each column represents a vector. Print the content of the matrix.-Big Data slip18

 Write an R program to create three vectors a,b,c with 3 integers. Combine the three vectors to become a 3×3 matrix where each column represents a vector. Print the content of the matrix.

 

 # Create three vectors a, b, and c with 3 integers each

a <- c(1, 2, 3)

b <- c(4, 5, 6)

c <- c(7, 8, 9)

 # Combine the vectors into a 3x3 matrix

matrix_result <- matrix(data = c(a, b, c), nrow = 3, byrow = FALSE)

 # Print the content of the matrix

print(matrix_result)