[R] "object not found" within function
Thushyanthan Baskaran
thushyanthan.baskaran at awi.uni-heidelberg.de
Mon Nov 2 19:32:22 CET 2009
Hi,
I am trying to write a function to compute many cross-tabulations with the -svytable- command. Here is a simplified example of the structure of my code (adapted from the -svytable- help file):
data(api)
func.example<-function(variable){
dclus1<-svydesign(id=~1, weights=~pw,data=apiclus1, fpc=~fpc)
svytable(~ variable, dclus1)
}
When I call this function with:
func.example(api99)
I get the following error:
Error in eval(expr, envir, enclos) : object 'variable' not found.
(Everything works fine when I type svytable(~ api99, dclus1).)
I guess that the problem has something to do with function environments, but since I am new to R, I can't seem to figure out how to rectify the code.
I am running R version 2.10 on Windows Vista.
Thanks for the help!
Thushyanthan
More information about the R-help
mailing list