browseVignettes: remove `source` and `R code ` files from output

142 Views Asked by At

I wrote an HTML vignette for my R package hosted on GitHub. When I open it with browseVignettes, it flawlessly opens on the browsers showing this content:

Vignettes found by browseVignettes("package_name")
Vignettes in package package_name
package_name file_name - HTML  source  R code 

clicking on HTML source R code it opens the same file in three different versions.

However, I don't need the source and the R code files to show.

Is there a way to output only the HTML file? As in the following output

Vignettes found by browseVignettes("package_name")
Vignettes in package package_name
package_name file_name - HTML   
1

There are 1 best solutions below

0
On

You can't easily drop the source, but you can drop the R code by setting that component to blank. For example,

allfields <- browseVignettes()
noR <- lapply(allfields, function(pkg) {pkg[,"R"] <- ""; pkg})
class(noR) <- class(allfields)
noR

If you really want to drop the source, then you'll need to get the print method and modify it:

print.browseVignettes <- utils:::print.browseVignettes
# Modify it as you like.