[R-pkg-devel] updating my package to fix if () condition has length > 1

peter dalgaard pdalgd at gmail.com
Sat May 5 01:19:26 CEST 2018


Um, what are you saying here? You are (AFAIK) not going to get that Error unless "method" has length > 1. It is not a synthetic check inserted by the CRAN nitpickers... Rather than "break the thermometer" by doing method[1], perhaps you should diagnose the problem, say by inserting something like

if (length(method) >= 1) {
 warning("'method' has length > 1:")
 print(method)
}

just before the "if (!is.element..." stuff.

-pd 

> On 4 May 2018, at 19:38 , Lawrence, John P <John.Lawrence at fda.hhs.gov> wrote:
> 
> In the check results, it has this message:
> "
>  Error in if (!is.element(substr(method, 1, 1), c("b", "P"))) { :
>    the condition has length > 1
>  Calls: AsympDiscSurv
>  Execution halted
> "
> 
> But, I had already changed that line to this:
> 
> if (!is.element(substr(method[1], 1, 1), c("b", "P"))) {
> 
> 
> I know the variable "method" is a single character string, but to handle the error checking, I now explicitly tell it to use "method[1]".

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-package-devel mailing list