Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Click on a URL from an R string output

Tags:

string

r

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?

like image 898
user39756 Avatar asked May 11 '17 19:05

user39756


1 Answers

As you mentioned in the comments you are using RStudio. We didnt here yet 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 ;) enter image description here

like image 155
Tonio Liebrand Avatar answered Oct 21 '22 04:10

Tonio Liebrand