嗨,我在下面的 .rmd 文档中有这个示例数据框,我想将其显示为带有kableExtra
包的表格。问题是我不能用第一列的“链接名”替换第二列的 url,并且仍然让它们作为 pdf 文档中的超链接工作。
---
title: "Clinical Table"
author: EK
date: January 29, 2018
output:
pdf_document:
keep_tex: yes
---
```{r nice-tab, tidy=FALSE,echo=FALSE,message=FALSE}
library(dplyr)
library(kableExtra)
library(rmarkdown)
library(knitr)
df<-data.frame(rep("linkname",10))
df$url<- c("https://en.wikipedia.org/wiki/Cadillac_Fleetwood",
"https://www.lincoln.com/luxury-cars/continental/",
"http://shop.honda.com/civics.aspx",
"https://bringatrailer.com/2011/12/28/striking-1973-maserati-bora-4-9/",
"https://en.wikipedia.org/wiki/Cadillac_Fleetwood",
"https://www.lincoln.com/luxury-cars/continental/",
"http://shop.honda.com/civics.aspx",
"https://bringatrailer.com/2011/12/28/striking-1973-maserati-bora-4-9/",
"https://en.wikipedia.org/wiki/Cadillac_Fleetwood",
"https://www.lincoln.com/luxury-cars/continental/")
names(df)[1]<-"name"
df$name<- paste("<a href=\"",df$url,"\">",df$name,"</a>",sep="")
kable(
df, caption = 'REPORT TABLE',
booktabs = TRUE,format = "latex",escape = FALSE
)%>%
kable_styling(full_width = T)
```