value.filter             package:memisc             R Documentation

_V_a_l_u_e _F_i_l_t_e_r_s

_D_e_s_c_r_i_p_t_i_o_n:

     Value filters, that is objects that inherit from class
     "value.filter", are a mechanism to distinguish between valid codes
     of a survey item and codes that are considered to be missing, such
     as the codes for answers like "don't know" or "answer refused".

     Value filters are optional slot values of "item" objects. They
     determine which codes of "item" objects are replaced by 'NA' when
     they are coerced into a vector or a factor.

     There are three (sub)classes of value filters: "missing.values",
     which specify individual missing values and/or a range of missing
     values; "valid.values", which specify individual valid values
     (that is, all other values of the item are considered as missing);
     "valid.range", which specify a range of valid values (that is, all
     values outside the range are considered as missing). Value filters
     of class "missing.values" correspond to missing-values
     declarations in SPSS files, imported by 'spss.fixed.file',
     'spss.portable.file', or 'spss.system.file'.

     Value filters also can be updated using the  '+' and '-'
     operators.

_U_s_a_g_e:

     value.filter(x)

     missing.values(x)
     missing.values(x)<-value

     valid.values(x)
     valid.values(x)<-value

     valid.range(x)
     valid.range(x)<-value

     is.valid(x)
     nvalid(x)
     is.missing(x)
     include.missings(x,mark="*")

_A_r_g_u_m_e_n_t_s:

 x,value: objects of the appropriate class.

    mark: a character string, used to pasted to value labels of 'x' (if
          present).

_V_a_l_u_e:

     'value.filter(x)', 'missing.values(x)', 'valid.values(x)', and
     'valid.range(x)', return the value filter associated with 'x', an
     object of class "value.filter", that is, of class
     "missing.values", "valid.values", or "valid.range", respectively.

     'is.missing(x)' returns a logical vector indicating for each
     element of 'x' whether it is a missing value or not. 'is.valid(x)'
     returns a logical vector indicating for each element of 'x'
     whether it is a valid value or not. 'nvalid(x)' returns the number
     of elements of 'x' that are valid.

     For convenience, 'is.missing(x)' and 'is.valid(x)' also work for
     atomic vectors and factors, where they are equivalent to
     'is.na(x)' and '!is.na(x)'. For atomic vectors and factors,
     'nvalid(x)' returns the number of elements of 'x' for which
     '!is.na(x)' is TRUE.

     'include.missings(x,...)' returns a copy of 'x' that has all
     values declared as valid.

_E_x_a_m_p_l_e_s:

     x <- rep(c(1:4,8,9),2,length=60)
     labels(x) <- c(
         a=1,
         b=2,
         c=3,
         d=4,
         dk=8,
         refused=9
         )
     missing.values(x) <- 9
     missing.values(x)
     missing.values(x) <- missing.values(x) + 8
     missing.values(x)
     missing.values(x) <- NULL
     missing.values(x)
     missing.values(x) <- list(range=c(8,Inf))
     missing.values(x)
     valid.values(x)
     print(x)
     is.missing(x)
     is.valid(x)
     as.factor(x)
     as.factor(include.missings(x))
     as.integer(x)
     as.integer(include.missings(x))

