Is it possible to reference multiple variables with the same prefix in R? Suppose you have a series of variables (A1, A2... Ax). I would like to define a series of variables (B1, B2... Bx) in terms of the A series of variables. The following example does not work, but I would like to define B1 and B2 as five times A1 and A2, respectively.
A1 <- 5
A2 <- 10
paste0("B",1:2) <- 5 * paste0("A",1:2)
In this case, the output should be: B1=25,B2=50. Is there a way to do this?