dependencies - Official guidelines for using functions newly added to base R -
i writing package performs statistical analysis while handling missing values. using wonderful, life-changing function anyna
added sometime after 3.0 (commit). added function people might want use olsonnames
.
so using function, package won't work on older versions of r. see 4 options dealing this.
make whole package depend on r >= 3.1 in description.
redefine function in source.
redefine function if user using <3.1 , don't define if using >= 3.1 or make function check version each time e.g.
anyna <- function(x) if(as.numeric(r.version()$minor) > 3.1){ return(anyna(x) } else { return(any(is.na(x)) } }
or
if(as.numeric(r.version()$minor) > 3.1){ anyna <- base::anyna } else { anyna <- function(x) any(is.na(x)) }
i'm not sure second 1 work in package source code.
rewrite code using
any(is.na(x))
.
my concrete question is there official cran preference 1 of these?
failing that, there reasons use 1 on others? eyes have failings. 1) seems unnecessary require users have r >= 3.1 sake of small function. 2) if redefine function, improvements made function in r base won't used in package. 3) seems messy. also, if base r version of function changes might end hard fix bugs occur in r versions. 4) code readability reduced.
Comments
Post a Comment