[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-devel
Subject:    Re: [Rd] requireNamespace etiquette
From:       Prof Brian Ripley <ripley () stats ! ox ! ac ! uk>
Date:       2015-02-21 5:53:34
Message-ID: 54E81D5E.1060208 () stats ! ox ! ac ! uk
[Download RAW message or body]

On 20/02/2015 21:15, RKoenker wrote:
> I'm trying to resolve a problem of Namespaces and probably have misunderstood
> something basic.
> In my quantreg package the function crq() has as its first argument a
> formula that typically contains
> something like this: Surv(y, ...) ~ foo,  where Surv is a function from the
> survival package which
> quantreg suggests.  When this syntax is encountered in ordinary usage Surv
> is resolved, I believe,
> because near the beginning of the crq code there is the locution:
>
> if(!requireNamespace("survival", quietly = TRUE))
>          stop("crq requires survival package to be installed")
>
> However, when R CMD check tries to do one of the crq examples I see:
>
>> f <- crq(Surv(y,d,type = "left") ~ x, method = "Portnoy")
> Error in eval(expr, envir, enclos) : could not find function "Surv"
> Calls: crq ... eval -> model.frame -> model.frame.default -> eval -> eval
> Execution halted
>
> Can someone suggest a fix?

'Writing R Extensions'  §1.1.3.1 does.  Either use survival::Surv in that 
call, or if your code expects only 'Surv', have

Surv <- survival::Surv

somewhere in the environment tree where your formula is evaluated.

>
> Roger

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic