i trying include links particular webpages in 'kable' table in rmarkdown, when creating pdf.
the table has 4 columns, , wish links in second column, includes strings. output of table given below;
knitr::kable(ind_rank_table_final,row.names = false,caption = "industry rank",align = rep("l",ncol(ind_rank_table)))
using paste0, can construct markdown-formatted urls in dataframe, , pass kable, so:
--- output: pdf_document --- ```{r} # urls urls <- rep("https://stackoverflow.com/", 10) # use paste0 compose markdown-formatted hyperlinks mtcars$mpg <- paste0("[", mtcars$mpg, "](", urls, ")") # print table, hyperlinked text knitr::kable(head(mtcars)) ``` and can see result, blue text in mpg column, , if hover mouse over, see url:
if want print urls in table, , have them clickable, you'de mtcars$mpg <- paste0("[", urls, "](", urls, ")") so:
is you're after? use of paste0 pretty handy doing sorts of things tables, example, combining multiple values in 1 cell, , applying conditional formatting (like bold significant values)


Comments
Post a Comment