read.spss              package:foreign              R Documentation

_R_e_a_d _a_n _S_P_S_S _D_a_t_a _F_i_l_e

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

     'read.spss' reads a file stored by the SPSS 'save' and 'export'
     commands and returns a list.

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

     read.spss(file, use.value.labels=TRUE, to.data.frame=FALSE,
               max.value.labels=Inf, trim.factor.names=FALSE)

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

    file: character variable with the name of the file to read.

use.value.labels: Convert variables with value labels into R factors
          with those levels?

to.data.frame: return a data frame?

max.value.labels: Only variables with at most this many unique values
          will be converted to factors

trim.factor.names: Trim trailing spaces from factor levels?

_D_e_t_a_i_l_s:

     This uses modified code from the PSPP project for reading the SPSS
     formats. 

     Occasionally in SPSS value labels will be added to some values of
     a continuous variable (eg to distinguish different types of
     missing data), and you will not want these variables converted to
     factors.  By setting 'max.val.labels' you can specify that
     variables with a large number of distinct values are not converted
     to factors even if they have value labels. In addition, variables
     will not be converted to factors if there are non-missing values
     that have no value label. The value labels are then returned in
     the '"value.labels"' attribute of the variable.

     If SPSS variable labels are present, they are returned as the
     '"variable.labels"' attribute of the answer.

     Fixed length strings (including value labels) are padded on the
     right with spaces by SPSS, and so are read that way by R.   See
     the examples for 'sub' for ways to remove trailing spaces in
     string data.

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

     A list (or data frame) with one component for each variable in the
     saved data set.

_N_o_t_e:

     If SPSS value labels are converted to factors the underlying
     numerical codes will not in general be the same as the SPSS
     numerical values, since the numerical codes in R are always
     1,2,3,...

_A_u_t_h_o_r(_s):

     Saikat DebRoy

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

     ## Not run: 
     read.spss("datafile")
     ## don't convert value labels to factor levels
     read.spss("datafile",use.value.labels=FALSE)
     ## convert value labels to factors for variables with at most
     ## ten distinct values.
     read.spss("datafile",max.val.labels=10)
     ## End(Not run)

