The mospiR package downloads survey microdata from the MoSPI Microdata Portal. This portal is the data repository of the National Statistics Office (NSO) of India. The package uses the NADA API of the portal. The package sends your API key, reads all the pages of results, and tries a failed request again.
~/.Renviron:MOSPI_KEY=your_key_here
readRenviron("~/.Renviron") or start R again.list_datasets() gets all the pages and gives one data
frame. To find datasets by title, use the query argument.
The package compares query with the titles on your
computer. The function ignores the difference between upper case and
lower case letters.
download_file() writes one file to
folder_path. The function gives the local path of the file
as an invisible value.
path <- download_file(
dataset_id = "DDI-IND-NSO-ASI-2019-20",
file_name = "ASI_DATA_2019_20_CSV.zip",
folder_path = "data/asi-2019-20",
api_key = api_key
)download_dataset() downloads all the files in the
dataset:
paths <- download_dataset(
dataset_id = "DDI-IND-NSO-ASI-2019-20",
folder_path = "data/asi-2019-20",
api_key = api_key
)
length(paths)If the file name is not correct, download_file() shows
the names of the available files. Give the result of
list_files() in .files_cache. Then the
function does not get the file list again.
The portal has all the rounds of the Household Consumer Expenditure Survey (HCES). To get all the rounds, do these steps: