1

I would like to add clickable a hyperlink (e.g. https://cran.r-project.org/web/packages/tm.plugin.factiva/index.html) to a .R file.

I found a solution for a R markdown files (How do I add a URL to R markdown?), however, I could not find a solution to enter hyperlinks directly into .R files.

I thought about to add a hyperlink as #https://cran.r-project.org/web/packages/tm.plugin.factiva/index.html

Is there any other solution?

captcoma
  • 1,768
  • 13
  • 29
  • 2
    `.R` files are not generally interpreted in that manner, afaict. With R-markdown, for instance, most editors and rendering tools know what to do with `![alt text](https://...)`, but since R *source* is not typically displayed in a webpage sort of way, I don't think anything assumes to make anything url-like "clickable". Some editors likely do it, but it's completely on them to do the parsing and inference. (In which case ... just including the full URL might be sufficient.) – r2evans Sep 15 '20 at 22:49
  • 2
    In an R script in RStudio on Windows I can open a hyperlink included in a comment with Shift + Mouse Click. – aosmith Sep 15 '20 at 23:59

1 Answers1

1

If you want to document your R code with clickable hyperlinks (and formatted lists, typeset equations, etc.), I recommend roxygen2. RStudio offers excellent workflow support for creating documentation for "oxygenated" R code.

However if your intent is to write a "self-documenting" .R file, then your idea (of including a URL in a comment) is fine. The person who is reading your .R file will understand your intended reference even if you don't decorate your URL with the angle brackets or square brackets-and-parentheses that'd be required for it to be interpreted as a link in the document-compilation workflow for an oxygenated code.