I want to have the values 1, 2, and 3, stored in the variables A, B, and C respectively, so that if I write print(A), it should return 1, print(B) returns 2, etc. I want to have the variables A, B, and C as character values in a vector called my_variables . So for achieving that I have implemented the following:
my_variables <-c("A", "B", "C")
and I have the values 1, 2, 3, stored in a vector called my_values:
my_values <-1:3
I tried to use this, but it didn't quite work the way I wanted:
assign(my_variables, my_values)
This simply assigns "A" "B" "C" to the variable my_variables, but nothing is assigned to the variable A.
I can accomplish what I want to do with an array, but if there is a more efficient way to do this with vectorized operations? Is there a better way to approach this than using a loop?