Displaying 1 result from an estimated 1 matches for "hasnalev".
Did you mean:
hanalee
2012 Dec 13
0
Suggestion of change to reduce overhead of 'table'
...function 'addNA' in some cases. I suggest to change 'addNA', too. This is diff against https://svn.r-project.org/R/trunk/src/library/base/R/factor.R.
336d335
<? ???if (ifany & !any(is.na(x))) return(x)
338c337,339
<? ???if (!any(is.na(ll))) ll <- c(ll, NA)
---
>? ???hasNAlev <- any(is.na(ll))
>? ???if ((ifany || hasNAlev) && !any(is.na(x))) return(x)
>? ???if (!hasNAlev) ll <- c(ll, NA)
Instead of calling 'factor', 'addNA' can also change "levels" attribute and accordingly fill missing value in internal code of the factor...