In R, my dataframe "mydata" has various continuous variable and factors. E.g. "Age" and "IQ" are continuous, "TaskType" and "ClassType" are factorial. A general problem I have in R is that I am not sure how I can refer to a variable by constructing the name from the variable's name's component parts. Apologies in advance, I cannot find the adequate language to describe this (basic?) problem. Here is the example:
The following code works:
by(mydata$Age,mydata$TaskType, stat.desc)
But in order to address a large number of variables/factors I wanted to use something more generic like the following code, which does not work:
variablename="Age"
factorname="TaskType"
by(mydata$variablename,mydata$factorname, stat.desc)