Skip to content
Advertisement

How add target=”-blank” and open link in new browser?

I have below code. it pasts ID (in my Data) to a link. I would like to know where can I use target=”-blank” in this code to open it in a new browser?

DF <-data %>% 
mutate( link = paste0("<a href='https://enhancer.lbl.gov/cgi-bin/imagedb3.pl?form=presentation&show=1&experiment_id=", ID, "&organism_id=1","'>Link</a>")) 

output:

<a href='https://enhancer.lbl.gov/cgi-bin/imagedb3.pl?form=presentation&show=1&experiment_id=1912&organism_id=1'>Link</a>

Advertisement

Answer

Since you use shiny you can use tags$a:

tags$a(
  href = paste0("https://enhancer.lbl.gov/cgi-bin/imagedb3.pl?form=presentation&show=1&experiment_id=", ID, "&organism_id=1"), 
  target = "_blank",
  "Link"
)

As per your comment:

DF <- data %>% 
  mutate(
    link = as.character(tags$a(
      href = paste0("https://enhancer.lbl.gov/cgi-bin/imagedb3.pl?form=presentation&show=1&experiment_id=", ID, "&organism_id=1"), 
      target = "_blank",
      "Link"
    ))
  ) 
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement