Click on a URL from an R string output

r, string

Solution

As you mentioned in the comments you are using RStudio. It is not specified why it has to be the console in R, but I assume there is a good reason to display the links within RStudio and I assume the viewer pane on the right next to the console also works for you.

If that is the case you could do the following:

library(DT)    # for datatable() function
library(shiny) # for tags$a() function
data <- data.frame(link = toString(tags$a(href = paste0("http://google.de"), "google")))
datatable(data, escape = FALSE)

Very close to the console ;)

Problem

Suppose I have an output from the cat function of R which is a URL. For example: ``` cat("https://en.wikipedia.org/wiki/Statistics") # Output: https://en.wikipedia.org/wiki/Statistics ``` Is there any command on the cat function or any other thing so that the output https://en.wikipedia.org/wiki/Statistics becomes a clickable URL in the R console?

Original source