The problem is with this line:
baplot(mydata$args[2],mydata$argss[3])
Let's not even mention the typo... When you ask for mydata$args[2]
, R looks for a column named "args" in your data.frame. Obviously, there is no such column so you get NULL
. The programmatic way of extracting columns from a data.frame is using [
. The correct syntax should be:
baplot(mydata[args[2]],mydata[args[3]])
That should fix your problem.
(Also note that the [
operator, unlike $
, will throw an error if you are trying to extract a column that does not exist: a preferable feature IMHO.)