v1 = c(1,3,5,7,9)
v2 = c(2,4,6,8,10)
print("Original vectors:")
print(v1)
print(v2)
print("Combines the said two vectors by columns:")
result = cbind(v1,v2)
print(result)
print("Combines the said two vectors by rows:")
result = rbind(v1,v2)
print(result)
Sample Output:
[1] "Original vectors:"
[1] 1 3 5 7 9
[1] 2 4 6 8 10
[1] "Combines the said two vectors by columns:"
v1 v2
[1,] 1 2
[2,] 3 4
[3,] 5 6
[4,] 7 8
[5,] 9 10
[1] "Combines the said two vectors by rows:"
[,1] [,2] [,3] [,4] [,5]
v1 1 3 5 7 9
v2 2 4 6 8 10
Sample Output:
[1] "Original vectors:" [1] 1 3 5 7 9 [1] 2 4 6 8 10 [1] "Combines the said two vectors by columns:" v1 v2 [1,] 1 2 [2,] 3 4 [3,] 5 6 [4,] 7 8 [5,] 9 10 [1] "Combines the said two vectors by rows:" [,1] [,2] [,3] [,4] [,5] v1 1 3 5 7 9 v2 2 4 6 8 10need an explanation for this answer? contact us directly to get an explanation for this answer