Q:

Write a R program to combines two given vectors by columns, rows

0

Write a R program to combines two given vectors by columns, rows.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now