#' Document File
#'
#' @param ... file names, which will be used to look()
#' @param items item
#' @param years years
#' @param open logical. whether to open the document file url in browser
#'
#' @return url of document file
#' @export
#'
nhs_docFile_pc <- function(...,items,years,open=FALSE){
file_ext='update'
(years <- prepare_years(years))
(items <- prepare_items(items))
(d1 <- paste0(get_config_path(),'/',years,'/'))
(d2 <- lapply(d1, function(i) paste0(i,items)))
(d3 <- do.call(c,d2))
f1 <- list.files(path = d3,full.names = TRUE)
ck <- tools::file_ext(f1) %in% file_ext
(f2 <<- f1[ck])
pattern <- c(...)
if (is.null(pattern)){
if (length(f2)>0){
url <- sapply(f2, function(i) read.delim(i,comment.char = '#',check.names = FALSE)[1,'DOC url'])
names(url) <- NULL
if (open){
for (i in url) browseURL(i)
return(url)
}else{
return(url)
}
}else{
return()
}
}
fn <- do::file.name(f2) |> do::Replace0('\\.tsv') |> paste0('.')
ck <- lookl(x = fn,...,ignore.case = TRUE)
docfile <- f2[ck]
if (length(docfile)>0){
url <- sapply(docfile, function(i) read.delim(i,comment.char = '#')[1,'DOC url'])
names(url) <- NULL
if (open){
for (i in url) browseURL(i)
return(url)
}else{
return(url)
}
}else{
return()
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.