R/html_URL.R

Defines functions html_URL

Documented in html_URL

#' add URL
#'
#' @param x object
#' @param href url
#' @param name name or anchor
#' @param target new
#'
#' @return add URL
#' @export
#'
html_URL <- function(x,href=NULL,name=NULL,target="new"){
    if (do::left_equal(target,'new')){
        target="_blank"
        if (!is.null(href) & is.null(name)){
            sprintf('<a href="%s" target="%s">%s</a>',href,target,x)

        }else if (is.null(href) & !is.null(name)){
            sprintf('<a href="#%s">%s</a>',name,x)

        }else if (!is.null(href) & !is.null(name)){
            sprintf('<a href="%s#%s" target="%s">%s</a>',href,name,target,x)
        }
    }else{
        if (!is.null(href) & is.null(name)){
            sprintf('<a href="%s">%s</a>',href,x)

        }else if (is.null(href) & !is.null(name)){
            sprintf('<a href="#%s">%s</a>',name,x)

        }else if (!is.null(href) & !is.null(name)){
            sprintf('<a href="%s#%s">%s</a>',href,name,x)
        }
    }

}
yikeshu0611/nhanesR documentation built on Jan. 29, 2022, 6:08 a.m.