Description Usage Arguments Details Value Author(s)
This function reads SPSS data files using the function read.spss
from the foreign
package and converts all variables to class character
. Additionally, leading and trailing white spaces can be removed from character variables, numeric values can be padded with leading zeros for uniform width of all entries in a column, and identifier variables can be renamed (i.e. when consistently named identifier varables are desired for automated merging of multiple datasets with mergeData
).
1 2 |
file |
Name of the SPSS data file to be read in |
correctDigits |
Logical: whether values should be transformed to have uniform width in each column, see ‘Details’. |
truncateSpaceChar |
Logical: whether leading and trailing spaces should be removed from character variables. |
oldID |
Optional: A character string containing the ID name in the original SPSS dataset. |
newID |
Optional: A character string containing the ID name after reading in the data. |
If correctDigits=TRUE
, the values in each column are transformed to have uniform width by adding leading zeros. The width of a column is determined by the longest value in this column, e.g., if a column contains the values 1, 10, 100
the transformed column will be 001, 010, 100
. This can be useful if the values had leading zeros which were removed by reading in the SPSS file.
If oldID
and newID
are used, the ID variable in the SPSS dataset will be changed to newID
when the file is read.
A data frame. All columns are of class character
.
Nicole Haag, Sebastian Weirich
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.