Displaying 2 results from an estimated 2 matches for "ytext".
Did you mean:
text
2007 Jun 14
4
question about formula for lm
Dear all;
Is there any way to make this to work?:
.x<-rnorm(50,10,3)
.y<-.x+rnorm(50,0,1)
X<-data.frame(.x,.y)
colnames(X)<-c("Xvar","Yvar")
Ytext<-"Yvar"
lm(Ytext~Xvar,data=X) # doesn't run
lm(Yvar~Xvar,data=X) # does run
The main idea is to use Ytext as input in a function, so you just type
"Yvar" and the model should fit....
Also, I need to avoid the expression X$Yvar~X$Xvar
Thanks for any idea
PM
2007 Oct 17
1
passing arguments to functions within functions
...sys.parent()), groups,
subset,
xlab = NULL, ylab = NULL, ylim = NULL, panel = panel.xYplot,
prepanel = prepanel.xYplot, scales = NULL, minor.ticks = NULL,
...)
{ # data=df; groups=fac2
require("Hmisc")
require("grid")
require("lattice")
ytext <- as.character(formula[2])
yvname <- formula[[2]]
y <- eval(parse(text = ytext), data)
xexp <- formula[[3]]
if (length(xexp) > 1 && as.character(xexp[[1]]) == "|") {
xvname <- xexp[[2]]
byname <- xexp[[3]]
xtext...