[R] problem with substitute

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Thu Jul 18 17:32:05 CEST 2002


There is no standard R function `evaluate'.  What is its definition?

I suspect you need

kappa <- function(x)
{
    xx <- deparse(substitute(x), 500)
    a <- table(paste("p", xx, sep=""), paste("k", xx, sep=""))
    ...
}

On Thu, 18 Jul 2002, R. Heberto Ghezzo wrote:

> Hello, I have a data base with variables pasthma,kasthma,sex,etc.
> I wrote a program to compute the Kappa statistic between pasthma and
> kasthma.
> Actually "did the child had asthma" answered by the parents and by the
> child.
> kappa <- function(x) {
>   r <- paste("p",evaluate(x),sep="")
>  c <- paste("k",evaluate(x),sep="")
>  a <- table(r,c)
> ...
> }
> If I call "kappa(asthma)" it works as expected ( "by me"). But if I call
>
> "kappa(asthma[sex==1])" it does not because of evaluate
>  r is "p["  "pasthma"  "psex==1" and I intended to be "pasthma[sex==1]"
> Is there a way around, or I am using the wrong approach?
> Thanks for any help
> .
> Heberto Ghezzo Ph.D.
> McGill University
> Montreal - Canada
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
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