read_data: Reads files (fwf or csv).

Description Usage Arguments Examples

View source: R/main_import_functions.R

Description

Main import function. Parses metadata and import diciontaries (in case of fwf files) to obtain import parameters for the desired subdataset and period. Then imports based on those parameters. Should not be aceessed directly, unless you are trying to extend the package, but rather though the wrapper funtions (read_CENSO, read_PNAD, etc).

Usage

1
2
3
read_data(dataset, ft, i, metadata = NULL, var_translator = NULL,
  root_path = NULL, file = NULL, vars_subset = NULL, nrows = -1L,
  source_file_mark = F)

Arguments

dataset

.

ft

file type. Indicates the subdataset within the dataset. For example: "pessoa" (person) or "domicĂ­lio" (household) data from the "CENSO" (Census). For a list of available ft for the period just type an invalid ft (Ex: ft = 'aasfasf')

i

period. Normally period in YYY format.

metadata

(optional) metadata for the dataset. If not provided it is obtained using the function read_metadata(dataset)

var_translator

(optional) a data.frame containing a subdataset (ft) specific renaming dictionary. Rows indicate the variable and the columuns the periods.

root_path

(optional) a path to the directory where dataset was downloaded

file

(optional) file to read, ignore all metadata in this case

vars_subset

(optional) read only selected variables( named on the dictionary for fwf files or in the first row for delimited files)

nrows

(optional) read only n first rows

source_file_mark

(optional) TRUE/FALSE , if T create a variable with the filename that the observation was imported from, useful for datasets with lots of separated files( CENSO and RAIS)

Examples

1
2
3
4
5
6
7
8
## Not run: 
CSV data:
read_data('escola',2014,CensoEscolar_metadata)
read_data('escola',2014,CensoEscolar_metadata,CensoEscolar_escola_varname_harmonization)

FWF data: dictionary is mandatory
read_data('escola',2013,CensoEscolar_metadata,CensoEscolar_dics)
## End(Not run)

lucasmation/microdadosBrasil documentation built on Dec. 6, 2019, 7:14 p.m.