I have a dataframe and one of the columns is all urls. I am trying to turn them into links that display as "link". My homework assignment says that I should use the format [link](url)
, but it doesn't work for me to include my column name. How can I mutate my dataframe to turn the urls into links?
Asked
Active
Viewed 978 times
0

mouse
- 35
- 7
-
Is that a shiny app where you want clickable links? Maybe [this](http://stackoverflow.com/questions/17155382/putting-hyperlinks-into-an-html-table-in-r) or [this](http://stackoverflow.com/questions/32315372/rshiny-how-to-create-a-table-with-clickable-hyperlink) could help. – Ronak Shah Feb 07 '17 at 06:23
-
1http://rmarkdown.rstudio.com/authoring_basics.html `[linked phrase](http://example.com)` becomes [linked phrase](http://example.com) – Jean Feb 07 '17 at 06:26
1 Answers
0
Here is a sample Shiny app that will take a set of URLs and then display them as clickable links.
ui <- fluidPage(
dataTableOutput("myoutput")
)
server <- function(input, output, session){
require(DT)
myNames <- c("Google", "Facebook")
myURLs <- c("https://google.com", "https://facebook.com")
output$myoutput <- renderDataTable(escape = FALSE, {
df <- data.frame(Site_Name = myNames, Site_URL = myURLs )
df$Site_URL <- sapply(df$Site_URL, function(x)
toString(tags$a(href = x, x)))
df
})
}
shinyApp(ui = ui, server = server)

Ron Bertino
- 141
- 1
- 7