read_rpr {readroper}R Documentation

Reads Roper Center datasets

Description

Reads fixed-width ASCII roper files. Takes arguments in the format a Roper Center survey codebook provides

Usage

read_rpr(
  col_positions = NaN,
  widths = NaN,
  col_names = NaN,
  filepath = NaN,
  card_read = NaN,
  cards = NaN
)

Arguments

col_positions

starting position(s) to read

widths

width of value(s) to read

col_names

names of columns to return

filepath

data obj or filepath to read

card_read

card to read (if blank, reads a single card dataset)

cards

number of cards in dataset (if null, assumes single card)

Value

a dataframe with len(col_names) number of columns, assigned to the values of col_names

Examples

fwf_sample <- readroper_example('testMultiCard.txt')
cat(readr::read_lines(fwf_sample))
fwf_sample2 <- readroper_example('testSingleCard.txt')
cat(readr::read_lines(fwf_sample2))
# 1. Fixed width file, first card, multi-card
read_rpr(col_positions=c(1,2,4), widths=c(1,2,1),
col_names=c('V1','V2','V3'), filepath=fwf_sample, card_read=1, cards=2)
# 2 .Fixed width file, first card, single card
read_rpr(col_positions=c(1,2,4), widths=c(1,2,1),
col_names=c('V1','V2','V3'), filepath=fwf_sample2)
 # 3. Fixed width file, second card, multi-card
read_rpr(col_positions=c(1,2,4), widths=c(1,2,1),
col_names=c('V1','V2','V3'), filepath=fwf_sample, card_read=2, cards=2)


[Package readroper version 0.9.3 Index]