I have a function that uses readline
to allow the user to enter the name they want to give for a variable I will be creating for them. Let's call this "USER.DEFINED.VARIABLE". It contains the name I want to use for another variable. Let's say that "USER.DEFINED.VARIABLE" gets set by readline
to be "jimsfilename".
I know I can assign value to a variable named "jimsfilename" using:
assign(USER.DEFINED.VARIABLE,c(1,2,3,4,5))
"jimsfilename" will now have 1,2,3,4,5
in it. However, how do I now fuss with "jimsfilename", given that I don't (before readline assigns it to USER.DEFINED.VARIABLE) know what its name is?
In other words, lets say I now want to add 1 to every value in jimsfilename. I can't do:
USER.DEFINED.VARIABLE <- USER.DEFINED.VARIABLE + 1 # can't do this
because "USER.DEFINED.VARIABLE" is actually a text string name. I want instead to refer to jimsfilename, but all I have is USER.DEFINED.VARIABLE to indicate it. I'm sure this is something easy...