How can two vectors in R language be merged into one vector?
In R language, you can use the c() function to combine two vectors into one. Here is an example:
# 创建两个向量
vec1 <- c(1, 2, 3)
vec2 <- c(4, 5, 6)
# 合并两个向量
combined_vec <- c(vec1, vec2)
print(combined_vec)
The output result is:
[1] 1 2 3 4 5 6
In the above example, we first created two vectors, vec1 and vec2, using the c() function, and then merged them into a single vector called combined_vec using the c() function. By printing combined_vec, we can see that the two vectors have been successfully merged into one.