![]() Level (prints as ) by default, this is the last level. X, set exclude = NULL to make NA an extra X and will exclude the levels present in exclude. IfĮxclude is used, since R version 3.4.0, excluding non-existingĬharacter levels is equivalent to excluding nothing, and whenĪlternatively, exclude can be factor with the same level set as That case, a factor with the reduced level set is returned. NAs is a no-operation unless there are unused levels: in Which case the levels are that character string with a sequenceįactor(x, exclude = NULL) applied to a factor without This should eitherīe a set of new labels for the levels, or a character string, in The reduced set of levels after removing those in exclude, but Normally the ‘levels’ used as an attribute of the result are (which will happen for excluded values) then the i-th element If xĮquals levels, then the i-th element of the result is The encoding of the vector happens as follows. Ordered factors differ from factors only in their class, but methodsĪnd the model-fitting functions treat the two classes quite differently. The type of the vector x is not restricted it only must haveĪn as.character method and be sortable (by Ordered factors they must have the same level set. Mechanism precludes comparing ordered and unordered factors.Īll the comparison operators are available for ordered factors.Ĭollation is done by the levels of the operands: if both operands are Ordered factors are compared in the same way, but the general dispatch (not necessarily in the same ordering) or to a character vector. Only be compared to another factor with an identical set of levels Only = and != can be used for factors: a factor can Provide methods for the Comparison operators, There are "factor" and "ordered" methods for the ThisĬomparison operators and group generic methods Valid, otherwise a string describing the validity problem. valid.factor(object) checks the validity of a factor,Ĭurrently only levels(object), and returns TRUE if it is Level (so that NA values are counted in tables, for instance). It is an abbreviated (sometimes faster) form of factor.Īs.ordered(x) returns x if this is ordered, andĪddNA modifies a factor by turning NA into an extra Is.ordered returns TRUE when its argument is an orderedĪs.factor coerces its argument to a factor. ![]() Whether its argument is of type factor or not. ![]() Is.factor returns TRUE or FALSE depending on [.factor for a more transparent way to achieve this. Undocumentedly for a long time, factor(x) loses allĪpplying factor to an ordered or unordered factor returns aįactor (of the same type) with just the levels which occur: see also Is true (or ordered() is used) the result has class Set of integer codes the length of x with a "levels" Factor returns an object of class "factor" which has a
0 Comments
Leave a Reply. |