I want to create some variable names dynamically. After creation the variable name, I also want to use them.
For example, I want to create a variable name dynamically x_1 (at the time of i=1) and after create, I want to use this (x_1) in the next line.
threshold <- 0.5
length <- 2
for (i in 1:3) {
assign(paste('x', i, sep='_'), 1)
assign(paste('y', i, sep='_'), x + (threshold * 0.2) - (length - 1.3)) // here I want the name (and value) of the `x` based on `i`
assign(paste('z', i, sep='_'), y * i + 2) // // here I want the name (and value) of the `y` based on `i`
}
Can you give me any idea?
Thank you