.Nesstar is the file
format of Nesstar Publisher. Nesstar Publisher is survey documentation
software from the International
Household Survey Network (IHSN). Statistical agencies, for example
the Ministry of Statistics and Programme Implementation (MoSPI), India,
publish survey microdata in this format. nesstarR reads these files in
R. You do not need Nesstar software.
This vignette uses a small synthetic file that comes with the package. For an example with real survey data, refer to the article “Read NSS 68 data from the MoSPI portal” on the package website.
nesstar_parse() decodes the resource index, the dataset
descriptors and the variable directories. It does not decode row data,
and it does not keep the file in memory. The other functions read only
the bytes that they need from the file.
One .Nesstar file can contain many datasets.
nesstar_datasets() gives the number of rows and variables
in each dataset.
nesstar_variables() gives the storage format of each
variable in one dataset. Mode 5 is a numeric variable. Mode 1 is a
string variable.
nesstar_read_dataset() decodes one dataset into a data
frame. Missing values become NA.
nesstar_read_dataset(x, dataset_number = 1)
#> AGE GROUP INCOME NAME
#> 1 25 11 1500.5 ab
#> 2 40 12 NA cde
#> 3 NA NA 0.0
#> 4 63 13 2000000.0 wxyzTo decode only some columns, use the columns
argument.
Many .Nesstar files contain XML blocks with variable
labels and category codes. nesstar_metadata() decodes these
blocks.
meta <- nesstar_metadata(x)
meta$datasets[[1]]$variables[[1]]
#> $name
#> [1] "AGE"
#>
#> $label
#> [1] "Age in years"
#>
#> $categories
#> list()Some older files do not contain these blocks. For these files,
nesstar_metadata() gives a warning and returns
NULL.
nesstar_export() writes each dataset to a different CSV
file. By default, it reads 50,000 rows at a time and writes gzip files.
Thus, the memory use stays low for large files.