myplot <- function(varname){
    myformula<-as.formula(paste(deparse(substitute(varname)),"~Y"))
    xyplot(myformula, group = Z, data = DF)
}.


Justin BEM
Elève Ingénieur Statisticien Economiste
BP 294 Yaoundé.
Tél (00237)9597295.

----- Message d'origine ----
De : Diego Gruber <diego.gruber@gmail.com>
À : r-help@stat.math.ethz.ch
Envoyé le : Jeudi, 14 Juin 2007, 11h53mn 38s
Objet : [R] function with xyplot

Hi,

I'm a new user trying to switch from SAS, so sorry for the beginner's
question: Suppose I have a dataframe DF that contains variables X,Y,Z. I am
trying to write a function like this:

myplot <- function(varname){xyplot(varname ~ Y, group = Z, data = DF)}.

The problem is then how to enter X into my function. If I write myplot("X")
I get an error because the argument is a string and xyplot can make nothing
out of it. If I write myplot(X) I also get an error that tells me the object
X does not exist.

Thanks for your help,

Diego

    [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.







      ______________________________________________________________________________ 

ail !
	[[alternative HTML version deleted]]

