create_a_link | R Documentation |
<a></a>
or in the form of image as <a><img /></a>
.Generate a HTML link as <a></a>
or in the form of image as <a><img /></a>
.
create_a_link(
href,
text,
href_rel_start = NULL,
target = "_blank",
do_cat = FALSE,
...
)
create_img_link(
href,
img_src,
href_rel_start = NULL,
img_src_rel_start = NULL,
img_width = "250px",
img_height = "",
target = "_blank",
do_cat = FALSE,
...
)
href |
A character scalar or vector (for |
text |
A character scalar or vector (for |
href_rel_start |
A character scalar: relative start of |
target |
A character scalar: |
do_cat |
A logical scalar: if |
... |
Named parameters to put in the resulting |
img_src |
A character scalar: path to image. |
img_src_rel_start |
A character scalar: same as |
img_width , img_height |
A character scalar: image size. |
A character scalar.
Sometimes URL in the supplied href
parameter is absolute, or not relative to the output in which will be displayed.
For such cases use the href_rel_start
parameter, which allows to make href
relative to something.
For example, you are saving a plot to a file relative to working directory, output/plots/plot.pdf
, and you want
to include link to this file in your RMarkdown output, output/report.html
.
From the point of view of this HTML file, output/plots/plot.pdf
obviously does not exist.
However, you can use href_rel_start = "output"
to specify that the href
is relative to this directory,
resulting in a link to plots/plot.pdf
.
Thanks to fs::path_rel()
, which is used underhood, even non-children href
can be used, e.g.
if HTML is located in output/reports/report.html
, than href_rel_start = "output/reports"
will result in a link
to ../plots/plot.pdf
.
create_a_link("google.com", "Google")
# If you want to reference a file relative to HTML saved in "output/report.html"
create_a_link("output/plots/plot.pdf", "Link to plot", href_rel_start = "output")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.