[Rd] Internal codes of the factor
Berwin A Turlach
berwin at maths.uwa.edu.au
Wed Mar 15 03:30:08 CET 2006
G'day Gregor,
>>>>> "GG" == Gregor Gorjanc <gregor.gorjanc at bfro.uni-lj.si> writes:
GG> I am writing some functions and I repeatedly acces internal
GG> factor codes. I figured out that internal codes are 1:n where
GG> 1 represents 1st level, 2 2nd level etc. This is not
GG> documented [...]
The help page for factor states in the 'Details' section:
The encoding of the vector happens as follows. First all the
values in 'exclude' are removed from 'levels'. If 'x[i]' equals
'levels[j]', then the 'i'-th element of the result is 'j'. If no
match is found for 'x[i]' in 'levels', then the 'i'-th element of
the result is set to 'NA'.
Note in particular the part on "then the 'i'-th element of the result
is 'j'". This pretty much documents that the internal codes are 1:n
and 'NA', as documented in the following sentence.
Cheers,
Berwin
========================== Full address ============================
Berwin A Turlach Tel.: +61 (8) 6488 3338 (secr)
School of Mathematics and Statistics +61 (8) 6488 3383 (self)
The University of Western Australia FAX : +61 (8) 6488 1028
35 Stirling Highway
Crawley WA 6009 e-mail: berwin at maths.uwa.edu.au
Australia http://www.maths.uwa.edu.au/~berwin
More information about the R-devel
mailing list