From berwin at maths.uwa.edu.au  Wed Mar 15 03:30:08 2006
From: berwin at maths.uwa.edu.au (Berwin A Turlach)
Date: Wed, 15 Mar 2006 10:30:08 +0800
Subject: [Rd] Internal codes of the factor
In-Reply-To: <44169B27.9020908@bfro.uni-lj.si>
References: <44169B27.9020908@bfro.uni-lj.si>
Message-ID: <17431.31792.677194.884181@bossiaea.maths.uwa.edu.au>

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



[Rd] Internal codes of the factor
Berwin A Turlach