This function searches for references stored in the sysdata.dta
object in package pkg
. If refcode
is a reference
then
load_reference(
refcode = NULL,
element = c("all", "table", "index", "study"),
pkg = "centile",
verbose = FALSE
)
String, code of a reference. Only the first element is loaded.
Alternatively, if refcode
is a reference, the function uses it.
Keyword, either "all"
, "table"
, "index"
or "study"
.
The default is "all"
.
The package containing the reference. The package must be loaded
and attached. The default pkg = "centile"
searches in the home package.
For more verbose output, set to TRUE
.
The return value depends on the element
parameter.
element | Return value |
"all" | All stored information |
"table" | A tibble with reference values |
"index" | Numeric vector with index values |
"study" | Named character vector with study data |
# use a built-in reference
ref <- load_reference("who_2006_wgt_male_")
head(ref)
#> # A tibble: 6 × 4
#> x L M S
#> <dbl> <dbl> <dbl> <dbl>
#> 1 0 0.349 3.35 0.146
#> 2 0.0027 0.313 3.32 0.147
#> 3 0.0055 0.303 3.34 0.147
#> 4 0.0082 0.296 3.36 0.146
#> 5 0.011 0.290 3.39 0.146
#> 6 0.0137 0.286 3.42 0.146
head(attr(ref, "study"))
#> name year yname sex distribution citation
#> "who" "2006" "wgt" "male" "LMS" "WHO 2006"
# use verbose = TRUE to find out problems
ref <- load_reference("nl_1997_hgt_male_nl", verbose = TRUE)
#> Warning: Reference nl_1997_hgt_male_nl not found in package centile.