'How to remove the </a tag when downloading a CSV file with hyperlinks in it using the DT package?

In the following example, I created a simple datatable. The third column contains hyperlinks. The datatable also contains a button allowing users to download the table as a CSV.

However, in the downloaded CSV, the third row contains the </a tag at the end, as the second screenshot shows. I wonder if it is possible to remove </a?

library(DT)

dat <- data.frame(
  ID = 1:2,
  Name = c("MSN", "Wikipedia"),
  Link = c('<a href=\"https://www.msn.com/en-us"download target=\"_blank\">MSN</a',
           '<a href=\"https://en.wikipedia.org/wiki/Main_Page"download target=\"_blank\">Wikipedia</a'))

datatable(dat,
          escape = FALSE,
          extensions = "Buttons",
          options = list(
            dom = "Bfrtip",
            buttons = list(
              list(
                extend = "csv",
                filename = "Data"
              )
          )))

enter image description here

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source