Let's say I have vectors x_1, x_2, x_3 and a vector with their names:
x_1<-1:3
x_2<-3:5
x_3<-7:9
names<-c("x_1", "x_2", "x_3")
Is it possible to address those vectors using another vector with their names ? For example:
for (i in 1:length(names)) {
print(paste0("x_",i)/2)
}
The example doesn't work, but that's what I'd like to do. Is there any function like "as.name" or whatever that converts paste0 output into a variable name ? Thank you!