Skip to contents

NIS datasets can be challenging to work with as the .ASC files do not include information about the variables, labels, or NA values. The read_nis() function reads the .ASC file and returns a R object with the correct variable names and NA values.

Usage

read_nis(
  file,
  year,
  import_method = "readr",
  col_select = NULL,
  n_max = Inf,
  corrected = TRUE
)

Arguments

file

Path to NIS dataset file.

year

The year of the dataset.

import_method

The function to import data. The default is readr.

col_select

Columns to include in the results. Columns can be selected by name or by a numerical column index.

n_max

The maximum number of rows/observations. The default is set all rows (Inf).

corrected

The official corrections will be applied to the data. The default is set to TRUE.

Value

Returns a tibble

Examples

# Read in the example NIS 2019 dataset.
if (FALSE) { # \dontrun{
NIS_2019_df <- read_nis("NIS_2019_test_data.ASC", 2019)
} # }

# Read in the first 5 observations of the example NIS 2019 dataset.
if (FALSE) { # \dontrun{
NIS_2019_df <- read_nis("NIS_2019_test_data.ASC", 2019, n_max = 5)
} # }

# Read in the first three diagnostic codes un the first 10 observations of
# the example NIS 2019 dataset.
if (FALSE) { # \dontrun{
NIS_2019_df <- read_nis("NIS_2019_test_data.ASC", 2019,
col_select = c("I10_DX1", "I10_DX2", "I10_DX3"), n_max = 10)

# This can also be done with:
NIS_2019_df <- read_nis("NIS_2019_test_data.ASC", 2019,
col_select = 19:21, n_max = 10)
} # }