Skip to content

Commit

Permalink
Enable hyperlink embedding in required_cols [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed Sep 12, 2022
1 parent 6c52a8b commit 5b519cd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 15 additions & 2 deletions R/required_cols.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
#' @param add_sources Add source code URLs for each method.
#' @param add_citations Add citations for each method.
#' @param add_executables Add path to executables for each method.
#' @param embed_links For any columns that contain URLs,
#' embed them as links with shortened names.
#' @param verbose Print messages.
#' @source \href{https://stackoverflow.com/a/43670036}{embedding knitr links}
#'
#' @export
#' @importFrom data.table data.table setkey
#' @examples
Expand All @@ -19,6 +23,7 @@ required_cols <- function(dataset_type = "GWAS",
add_sources = TRUE,
add_citations = TRUE,
add_executables = FALSE,
embed_links = FALSE,
verbose = TRUE){

#### Add required cols ####
Expand Down Expand Up @@ -77,7 +82,11 @@ required_cols <- function(dataset_type = "GWAS",
COJO_stepwise="https://github.com/jianyangqt/gcta",
COJO_conditional="https://github.com/jianyangqt/gcta",
COJO_joint="https://github.com/jianyangqt/gcta")
d$source <- source_dict[d$method]
if(isTRUE(embed_links)){
d$source <- paste0("[source](",source_dict[d$method],")")
} else {
d$source <- source_dict[d$method]
}
}
#### Extract executable paths ####
if(isTRUE(add_executables)){
Expand Down Expand Up @@ -110,7 +119,11 @@ required_cols <- function(dataset_type = "GWAS",
COJO_stepwise="https://doi.org/10.1038/ng.2213",
COJO_conditional="https://doi.org/10.1038/ng.2213",
COJO_joint="https://doi.org/10.1038/ng.2213")
d$citation <- as.character(citations_dict[d$method])
if(isTRUE(embed_links)){
d$citation <- paste0("[cite](",citations_dict[d$method],")")
} else {
d$citation <- citations_dict[d$method]
}
}
data.table::setkey(d, "method")
return(d)
Expand Down
7 changes: 7 additions & 0 deletions man/required_cols.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5b519cd

Please sign in to comment.