[R] pasing names

Prof Brian D Ripley ripley at stats.ox.ac.uk
Wed Jul 19 20:39:26 CEST 2000


On Wed, 19 Jul 2000, Heberto Ghezzo wrote:

> Hi, I wrote the simple program below, I want 'bartlett.test' to print the 
> real name of the variables, not the dummys 'y' and 'g', Can 
> somebody in the list tell me how to pass the names?
> .
> test <- function(y,g){
> #  some other stuff
>    bartlett.test(y,g)
> #    some other stuff
> }
> Thanks.

Use substitute, e.g.

testit <- function(y, g)
{
	eval.parent(substitute(bartlett.test(y,g)))
}
data(InsectSprays)
testit(InsectSprays$count, InsectSprays$spray)


         Bartlett test for homogeneity of variances 

data:  InsectSprays$count and InsectSprays$spray 
Bartlett's K-square = 25.9598, df = 5, p-value = 9.085e-05 

as required, I assume?

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list