4. Combining vectors


Not only you can perform arithmetic operations to vectors, but you can also “merge” them or combine them. To do so, simply use the concatenate function c(...) to concatenate the two vectors,:

[code language=”r”]
data1 = c("aa","bb","cc","dd","ee")
data2 = c(10,20)

c(data1,data2)
[/code]

 

concatenate vectors

The example above is a bit particular because it illustrates an unusual situation: a vector containing text and a vector containing numbers have been combined. As you see, it is possible to combine them, but the numbers had to be converted into text, hence the quotation marks.

  Fant du det du lette etter? Did you find this helpful?
[Average: 0]