Append a Single Value to Vector

Here we are going to append a value for an existing vector.

Syntax:

c(existing_vector,new)

where,

  • existing_vector is the vector
  • new is the values to be appended

Example:

R




# create  vector
vector1 = c(1, 2, 3, 4, 5)
  
# display
print(vector1)
  
# append 34
vector1 = c(vector1, 34)
  
# display
vector1


Output:

[1] 1 2 3 4 5
[1]  1  2  3  4  5 34

How to Append Values to Vector Using Loop in R?

In this article, we will discuss how to append values to a vector using a loop in R Programming Language. 

Similar Reads

Appending values to an empty vector

Here we are going to append the values using for loop to the empty vector....

Perform Operation and Append Values to Vector

...

Append a Single Value to Vector

Here we are going to perform some numeric operations and append values to the empty vector. We can perform cube operation and append to empty vector....

Append Multiple Values to Existing Vector

...

Contact Us