Adding custom R code before `pkgdown` parses the examples for the reference section

42 Views Asked by At

I'm using the pkgdown package to generate a website for my package.

I have some functions that have examples outputing some wide data.frame. Within the .Rd file included with the package, this cause no problem at all since the output is not printed in the help file.

However, I'd like to have the outputs of the examples in the reference section of my website. I was wondering if there was any way to print them wide and allow the user to scroll the entire code block horizontally instead of printing them in different successive small blocks of smaller width.

Basically, I'm wondering if it is possible to add a line of code that would set a very large value for options("width") without having to explicitly write it in the @examples section of each of my functions. As I wrote above, that would have no impact at all on the .Rd file since the output is not written anywhere, only on the reference section of the website which shows the output.

Sorry, it would be very complicated to include a reprex to my question, but in other words, I would like to go from this

> temp <- data.frame(
    col_a=runif(10L),
    col_b=runif(10L),
    col_c=runif(10L),
    col_d=runif(10L),
    col_e=runif(10L),
    col_f=runif(10L),
    col_g=runif(10L),
    col_h=runif(10L),
    col_i=runif(10L),
    col_j=runif(10L)
  )
> temp
#>           col_a      col_b      col_c      col_d      col_e     col_f      col_g      col_h
#>  1  0.181323854 0.75104009 0.73686474 0.05727037 0.29610696 0.6867088 0.31064183 0.41486704
#>  2  0.139670928 0.38722955 0.89132922 0.48052162 0.40036335 0.7600544 0.11146335 0.45366888
#>  3  0.983538559 0.52301261 0.13261336 0.33419294 0.35374823 0.8978582 0.57654460 0.53981790
#>  4  0.329538319 0.97686175 0.01113939 0.04592206 0.53903584 0.9239267 0.75733506 0.52384003
#>  5  0.957548071 0.09184554 0.73681737 0.86081372 0.87264370 0.3037857 0.02704224 0.89664443
#>  6  0.094074473 0.27192045 0.77752562 0.03920754 0.01984371 0.8940678 0.07152962 0.03730923
#>  7  0.306104152 0.19515733 0.08599808 0.46451691 0.54763343 0.7485412 0.21308091 0.67143356
#>  8  0.186864262 0.14957408 0.68869429 0.87882058 0.68898674 0.7393568 0.89282819 0.16698322
#>  9  0.002336095 0.91009819 0.98286170 0.04675676 0.70413771 0.4094106 0.17991418 0.44547507
#>  10 0.567136602 0.97059813 0.09369430 0.37421010 0.44803713 0.8156434 0.92656941 0.61773025
#>          col_i      col_j
#>  1  0.87505584 0.53716132
#>  2  0.36328509 0.56461640
#>  3  0.03963683 0.70108982
#>  4  0.15013992 0.29089908
#>  5  0.56193885 0.58433818
#>  6  0.24583356 0.13144550
#>  7  0.33987205 0.07785576
#>  8  0.68921547 0.88915648
#>  9  0.53836039 0.64969266
#>  10 0.13466480 0.49925536

to this

> temp
#>           col_a      col_b      col_c      col_d      col_e     col_f      col_g      col_h      col_i      col_j
#>  1  0.181323854 0.75104009 0.73686474 0.05727037 0.29610696 0.6867088 0.31064183 0.41486704 0.87505584 0.53716132
#>  2  0.139670928 0.38722955 0.89132922 0.48052162 0.40036335 0.7600544 0.11146335 0.45366888 0.36328509 0.56461640
#>  3  0.983538559 0.52301261 0.13261336 0.33419294 0.35374823 0.8978582 0.57654460 0.53981790 0.03963683 0.70108982
#>  4  0.329538319 0.97686175 0.01113939 0.04592206 0.53903584 0.9239267 0.75733506 0.52384003 0.15013992 0.29089908
#>  5  0.957548071 0.09184554 0.73681737 0.86081372 0.87264370 0.3037857 0.02704224 0.89664443 0.56193885 0.58433818
#>  6  0.094074473 0.27192045 0.77752562 0.03920754 0.01984371 0.8940678 0.07152962 0.03730923 0.24583356 0.13144550
#>  7  0.306104152 0.19515733 0.08599808 0.46451691 0.54763343 0.7485412 0.21308091 0.67143356 0.33987205 0.07785576
#>  8  0.186864262 0.14957408 0.68869429 0.87882058 0.68898674 0.7393568 0.89282819 0.16698322 0.68921547 0.88915648
#>  9  0.002336095 0.91009819 0.98286170 0.04675676 0.70413771 0.4094106 0.17991418 0.44547507 0.53836039 0.64969266
#>  10 0.567136602 0.97059813 0.09369430 0.37421010 0.44803713 0.8156434 0.92656941 0.61773025 0.13466480 0.49925536

in the reference section of the website.

0

There are 0 best solutions below