To add a value to a vector in R, you can use the c() function to concatenate the existing vector with the new value. Here's an example:
main.r148 chars9 lines
Output:
main.r12 chars2 lines
In this example, we first create a vector called my_vector with the values 1, 2, and 3. To add a value to the end of the vector, we use the c() function to concatenate my_vector with the value 4. Finally, we view the updated my_vector with the new value using the print() function.
gistlibby LogSnag