I'm trying generate effcient code to create a vector that is used to replace names of variables in a dataframe to function in a larger script. More specifically, I want to change "A1" to "A.1" and "A2" to "A.2" and so on up to "'Letter'.8. I succeeded in a loop that does this, but cannot seem to output it to a vector. Below is the code and the output. I've tried various ways to vectorize the output based on similar questions, but nothing has worked...
#1 define letter vector and add function
v1 = LETTERS[1:10]
add = function(x, inc = 1) {
y <- x + inc
}
#create loop to generate desired names
d <- add(0)
while (d < 9) {
for (l in v1) {
print(paste(l,".",d))
}
d <- add(d)
}