How can you combine two vectors in R language?
In R language, you can merge two vectors into one using the `c()` function. Here is an example:
# 创建两个向量vec1 <- c(1, 2, 3)
vec2 <- c(4, 5, 6)
# 合并两个向量
combined_vec <- c(vec1, vec2)
# 输出合并后的向量
print(combined_vec)
The output is:
[1] 1 2 3 4 5 6
In this example, we first create two vectors, `vec1` and `vec2`, using the `c()` function, which contain integers from 1 to 3 and 4 to 6 respectively. Then, we combine these two vectors into a new vector using the `c()` function called `combined_vec`. Finally, we print the merged vector using the `print()` function.