import_ascii: Import ASCII datasets using SPSS syntax files

View source: R/import_ascii.R

import_asciiR Documentation

Import ASCII datasets using SPSS syntax files

Description

import_ascii imports ASCII data files using their associated SPSS setup files.

Usage

import_ascii(data_file, setup_file, card_pattern, respondent_pattern)

Arguments

data_file

A path to an ASCII data file.

setup_file

A path to the corresponding SPSS setup file.

card_pattern

For use when the file does not contain a line for every card for every respondent (or contains extra lines that correspond to no respondent), a regular expression that matches the file's card identifier; e.g., if the card number is stored in the last digit of each line, "\d$".

respondent_pattern

For use when the file does not contain a line for every card for every respondent (or contains extra lines that correspond to no respondent), a regular expression that matches the file's respondent identifier; e.g., if the respondent number is stored in the first four digits of each line, preceded by a space, "(?<=^\s)\d4".

total_cards

For multicard files, the number of cards in the file.

var_names

A string vector of variable names.

var_cards

For multicard files, a numeric vector of the cards on which var_names are recorded.

var_positions

A numeric vector of the column positions in which var_names are recorded.

var_widths

A numeric vector of the widths used to record var_names.

Details

Many older survey datasets are available only in ASCII format, which is notoriously difficult to work with. The 'import_ascii' function imports uses the SPSS setup file to import data stored in this archaic format.

See read_rpr and read_roper for implementations that read single, specified variables.

Value

A data frame


fsolt/readascii documentation built on April 12, 2022, 3:11 p.m.