I am trying to figure out how to take a column name supplied by a user in response to a prompt in R and use that in the function factor. The idea is to create a script using ggplot2 that will allow users to easily select which variable from a table they would like coded by color and which by shape.
The line of code requesting user input would be:
> Color_Factor<-readline("What is the Column Heading of the Variable you would like separated by Color? ")
What is the Column Heading of the Variable you would like separated by Color? Reach
My problem is that I can't figure out how to use this input to call a particular column for graphing purposes. The code below creates a graph with one color and the single variable "Reach".
> qplot(d13C, d15N, data=InputFile, **col=factor(Color_Factor)**, shape=factor(Functional_Group))
All my attempts at calling a function as the initial argument in factor() have met with complete failure. I'm specifically interested in this for graphing purposes but am also wondering if there is a way to use the value of a variable rather than the variable name to specify a column in this type of function in general. I'm totally new to R so maybe there's an obvious solution but I haven't been able to find an answer online so far. Thanks