Nothing
getCodelist <- function(folder = NULL, codelistname = NULL){
# Finds the latest version of a CALIBER codelist from
# a folder
if (is.null(codelistname) & !is.null(folder)){
# search in the current working directory
codelistname <- folder
folder <- getwd()
} else if (is.null(folder)){
folder <- getwd()
}
# Find all the files in the repository
repository <- dir(folder, recursive = TRUE, full.names = TRUE)
# Get all versions of the codelist
candidates <- repository[grepl('[\\\\/]' %&% codelistname %&%
"\\.codelist\\.[0-9]+\\.(csv|dta)$", repository)]
# Extract the version numbers
version <- as.numeric(sub('^.*codelist\\.([0-9]+)\\.(csv|dta)$', '\\1',
candidates))
# Get the codelist with the maximum version
# If more than one codelist, print a warning
out1 <- NULL
out1 <- try(as.codelist(candidates[version == max(version)][1]))
if (length(candidates[version == max(version)]) == 2){
out2 <- NULL
out2 <- try(as.codelist(candidates[version == max(version)][1]))
if (!is.null(out2)){
comparison <- compare(out1, out2)
if (comparison$same_cattable &
comparison$same_terms){
if (!comparison$same_attr){
warning('Two codelists found with same terms but different metadata;\nonly one will be returned.')
}
} else {
warning('More than one codelist found; only one will be returned.')
}
}
} else if (length(candidates[version == max(version)]) > 1){
warning('More than one codelist found; only one will be returned.')
}
out1
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.