
I am running R version 2.15.1 in Windows XP

I am having problems with a function I'm trying to create to:
   1. subset a data.frame based on function arguments  (colname & parmname)
   2. rename the PARMVALUE column in the data.frame based on function
   argument (xvar)
   3. generate charts

  plotvar <- function(parentdf,colname, parmname,xvar,yvar ){
     subdf <- parentdf[substr(colname,1,nchar(parmname)) == parmname,]
     names(subdf) <- sub('PARMVALUE',xvar, names(subdf))
     xvarcol <- paste("subdf","$",xvar,sep="")
     yvarcol <- paste("subdf","$",yvar,sep="")
     hist(eval(parse(text = xvarcol)), xlab = xvar, main = paste
   ("Distribution of ",xvar,sep=""))
     boxplot(eval(parse(text = yvar))~HMA, ylab=yvar, xlab="HMA",
   data=subdf)
     plot(eval(parse(text = yvarcol))~eval(parse(text = xvarcol)), main =
   paste(yvar," by ",xvar, sep=""), xlab = xvar, ylab = yvar)
     scatterplot(eval(parse(text = yvar))~eval(parse(text = xvar)),
   boxplots='xy', data=subdf, main = "Testcase_ID=142")
 }

When I execute the function:
	plotvar(mydf,mydf$PARMNAME, "C_2TAMP","Amp_2T","C1")

everything seems to work until the scatterplot statement.  It posts this
error:

	Error in parse(text = yvar) : object 'yvar' not found

However, when I insert browser() statement before the scatterplot
statement:

   Browse[1]> ls()
   [1] "colname"  "parentdf" "parmname" "subdf"    "xvar"     "xvarcol"
   "yvar"     "yvarcol"

yvar is there, and the value is as expected
   Browse[1]> yvar
   [1] "C1"

Is this a quirk peculiar to scatterplot? (Note that boxplot which has
similar usage worked.)

I would appreciate any suggestions for how to resolve this, including a
different (better) approach.  mydf can have many different parameters
(parmnames), so I am trying to come up with a generalized function to plot
the data.

Regards,
**************** Elaine McGovern Jones ************************

             jones2@us.ibm.com




	[[alternative HTML version deleted]]

