Vectors in R programming is a basic object consisting sequence of homogenous elements. It can be integer, logical, double, character, complex or raw. In this article, let us discuss different methods to concatenate/append values to a vector in R programming. Values can be appended/concatenated in a vector using 2 methods:

- c() function
- append() function

#### Append operation using c() function

function is a generic function that combines data into a vector or a list.**c()**

Syntax:c(…)

Parameters:

…:represents objects to be concatenated

To know about more optional parameters, use below command in console:

help("c")

**Example 1:**

`# Create a vector ` `x <- 1:5 ` `n <- 6:10 ` ` ` `# Append using c() function ` `y <- ` `c` `(x, n) ` ` ` `# Print resultant vector ` `print` `(y) ` |

*chevron_right*

*filter_none*

**Output:**

[1] 1 2 3 4 5 6 7 8 9 10

**Example 2:**

`# Create vector ` `x <- 1:5 ` `n <- ` `letters` `[1:5] ` ` ` `# Append ` `y <- ` `c` `(x, n) ` ` ` `# Print resultant vector ` `print` `(y) ` ` ` `# Print type of resultant vector ` `typeof` `(y) ` ` ` `# Print type of other vectors ` `typeof` `(x) ` `typeof` `(n) ` |

*chevron_right*

*filter_none*

**Output:**

[1] "1" "2" "3" "4" "5" "a" "b" "c" "d" "e" [1] "character" [1] "integer" [1] "character"

#### Append operation using append() function

function in R is used for merging vectors or adding more elements to a vector.**append()**

Syntax:append(x, values)

Parameters:

x:represents a vector to which values has to be appended to

values:represents the values which has to be appended in the vector

**Example 1:**

`# Create a vector ` `x <- 1:5 ` ` ` `# Append using append() function ` `x <- ` `append` `(x, 6:10) ` ` ` `# Print resultant vector ` `print` `(x) ` |

*chevron_right*

*filter_none*

**Output:**

[1] 1 2 3 4 5 6 7 8 9 10

**Example 2:**

`# Create a vector ` `x <- 1:5 ` `y <- ` `letters` `[1:5] ` ` ` `# Append using append() function ` `x <- ` `append` `(x, values = y) ` ` ` `# Print resultant vector ` `print` `(x) ` |

*chevron_right*

*filter_none*

**Output:**

[1] "1" "2" "3" "4" "5" "a" "b" "c" "d" "e"

## Recommended Posts:

- Getting and Setting Length of the Vectors in R Programming - length() Function
- Create a Data Frame of all the Combinations of Vectors passed as Argument in R Programming - expand.grid() Function
- Compute the beta value of Non-Negative Numeric Vectors in R Programming - beta() Function
- Compute the Covariance between Two Vectors in R Programming - cov() Function
- Compute the Correlation Coefficient Value between Two Vectors in R Programming - cor() Function
- Creating a Data Frame from Vectors in R Programming
- Generating sequenced Vectors in R Programming - sequence() Function
- Find positions of Matching Elements between Vectors in R Programming - match() Function
- Generate Color Vectors of desired Length in R Programming - rainbow() Function
- Compute the Parallel Minima and Maxima between Vectors in R Programming - pmin() and pmax() Functions
- Assigning Vectors in R Programming
- Types of Vectors in R Programming
- Dot Product of Vectors in R Programming
- Cross Product of Vectors in R Programming
- Adding elements in a vector in R programming - append() method
- Operations on Vectors in R
- List of Vectors in R
- Create Matrix from Vectors in R
- Combine Vectors, Matrix or Data Frames by Columns in R Language - cbind() Function
- Combine Vectors, Matrix or Data Frames by Rows in R Language - rbind() Function

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.