VOOZH about

URL: https://www.geeksforgeeks.org/r-language/combine-vectors-matrix-or-data-frames-by-columns-in-r-language-cbind-function/

⇱ Combine Vectors, Matrix or Data Frames by Columns in R Language - cbind() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Combine Vectors, Matrix or Data Frames by Columns in R Language - cbind() Function

Last Updated : 15 Jul, 2025
cbind() function in R Language is used to combine specified Vector, Matrix or Data Frame by columns.
Syntax: cbind(x1, x2, ..., deparse.level = 1) Parameters: x1, x2: vector, matrix, data frames deparse.level: This value determines how the column names generated. The default value of deparse.level is 1.
Example 1: Output:
 x y
[1, ] 2 2
[2, ] 3 5
[3, ] 4 2
[4, ] 5 5
[5, ] 6 2
[6, ] 7 5
Example 2: Output:
 x 
[1, ] 1 4
[2, ] 2 4
[3, ] 3 4
[4, ] 4 4
[5, ] 5 4
 [, 1] [, 2]
[1, ] 1 5
[2, ] 2 5
[3, ] 3 5
[4, ] 4 5
[5, ] 5 5
 x 6
[1, ] 1 6
[2, ] 2 6
[3, ] 3 6
[4, ] 4 6
[5, ] 5 6
 [, 1] [, 2]
[1, ] 1 4
[2, ] 2 4
[3, ] 3 4
[4, ] 4 4
[5, ] 5 4
Comment

Explore