cl_filter {codelist}R Documentation

Filter a code list

Description

Filter a code list

Usage

cl_filter(codelist, locale, levels, check_levels = TRUE)

Arguments

codelist

a codelist object.

locale

use the codes from the given locale. Should be character vector of length 1. When NA the default locale is used (as returned by cl_locale.

levels

vector with levels on which to filter an hierarchical code list. Levels are numbered from 0 with 0 the topmost level. See 'Details'. When a code list does not have a 'parent' column and is, therefore, not hierarchical all codes are in level 0.

check_levels

if TRUE the parent column (if present) is removed from the result when the resulting code list would not be a valid hierarchy.

Details

When a code list has a 'parent' column. The codes without parent are assigned level 0. Codes with a parent in level 0 are assigned to level 1. Etc. When the code list does not have a 'parent' column all codes are assigned to level 0 (all codes are in the top level).

Value

Returns a codelist with the selected encoding and/or levels.


[Package codelist version 0.1.0 Index]