I have read the tutorial like this :[kable kableExtra, Cells with hyperlinks][1]
But I don't understand it totally.
My first question:
I just want to add only one hyperlink without changing its name.
What I can do is like this:
dt%>%kable(caption = "Sample information") %>%
kable_styling(bootstrap_options = c("striped"),full_width = F,html_font = "helvetica") %>%
column_spec(1, bold = T, border_right = F,width = "8cm") %>%
column_spec(2, width = "16cm")%>%
save_kable(file = "table1.html", self_contained = T)
Here is my sample data:
dt<-structure(list(GSE95401_EAE_Acute = c("Profiling the mouse brain endothelial transcriptome in health and disease models reveals a core blood-brain barrier dysfunction module",
"31611708", "https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE95401",
"EAE was induced by injecting the MOG35–55 peptide containing emulsion.",
"Mus musculus", "C57BL/6-Rosa-tdTomato", "2-3 months", "Spinal Cord",
"fluorescence-activated cell sorting (FACS)", "EAE Acute(Acute timepoints were taken on the first day that mice displayed a loss of 1 gram body weight.)",
"3", "EAE control", "3")), row.names = c("Original publication title",
"PMID", "Data source", "Disease/Treatment", "Species", "Strain",
"Age", "Organ", "EC isolation method", "Treated group information",
"Treated group replication no.", "Control group information",
"Control group replication no."), class = "data.frame")
And my second question is :
How can make the "Sample information " in my data with bold and front size change ?
I just wanna add only one hyperlink named "https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE95401" in my data but not multiple links
I mean somebody can click it and open a new web.
I used the R package KableExtra using cell_spec() and text_spec() but it doesn't work.
I hope somebody who can help me?
Date:2021年03月08日15:06:44. I find the right method:
dt[3,1]<-text_spec("https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE95401",
link = "https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE95401",color = "black",bold = T)
caption<-text_spec("Sample information",bold = T,font_size = 30,color = "black")
dt%>%kable(caption = caption,escape = FALSE) %>%
kable_styling(bootstrap_options = c("striped","hover","condensed"),full_width = F,html_font = 4) %>%
column_spec(1, bold = T, border_right = F,width = "8cm") %>%
column_spec(2, width = "16cm")%>%
save_kable(file = "table2.html", self_contained = T)
It works perfectly.
Since the final output that you want is an HTML file you can use HTML code to achieve what you want.
library(kableExtra)
dt%>%
kable(caption = "<a href = 'https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE95401'><b style = 'font-size : 28'>Sample information</b></a>") %>%
kable_styling(bootstrap_options = c("striped"),full_width = F,html_font = "helvetica") %>%
column_spec(1, bold = T, border_right = F,width = "8cm") %>%
column_spec(2, width = "16cm") %>%
save_kable(file = "table1.html", self_contained = T)