Skip to content

Instantly share code, notes, and snippets.

@lazycipher
Created June 6, 2020 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazycipher/76769ef1e2ca0e6cbf0d22f8669a9031 to your computer and use it in GitHub Desktop.
Save lazycipher/76769ef1e2ca0e6cbf0d22f8669a9031 to your computer and use it in GitHub Desktop.
knit-print-output
tests_run(filter = "knit")
[1] "knitting multiple animint plots in a single Rmd"
|.............. | 10%
ordinary text without R code
|............................ | 20%
label: safety (with options)
List of 1
$ echo: logi FALSE
|........................................... | 30%
ordinary text without R code
|......................................................... | 40%
label: plot-1-top
|....................................................................... | 50%
ordinary text without R code
|..................................................................................... | 60%
label: plot.1.bottom
|................................................................................................... | 70%
ordinary text without R code
|.................................................................................................................. | 80%
label: boring
|................................................................................................................................ | 90%
ordinary text without R code
|..............................................................................................................................................| 100%
label: breakpoints
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS index.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output index.html --email-obfuscation none --standalone --section-divs --template "C:\Users\imhim\Documents\R\win-library\4.0\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\imhim\AppData\Local\Temp\RtmpgHoa3W\rmarkdown-str3fac27a14de.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --lua-filter "C:/Users/imhim/Documents/R/win-library/4.0/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "C:/Users/imhim/Documents/R/win-library/4.0/rmarkdown/rmd/lua/latex-div.lua"
-- 1. Failure: knit_print.animint renders five x axis titles (@test-renderer1-kn
`value.vec` not identical to `expected.vec`.
Modes: list, character
Length mismatch: comparison on first 0 components
-- 2. Failure: segments and breakpoints are rendered (@test-renderer1-knit-print
length(seg.list) not equal to 6.
1/1 mismatches
[1] 0 - 6 == -6
-- 3. Failure: segments and breakpoints are rendered (@test-renderer1-knit-print
length(break.list) not equal to 5.
1/1 mismatches
[1] 0 - 5 == -5
-- 4. Error: svg id property is unique (@test-renderer1-knit-print.R#39) ------
incorrect number of dimensions
Backtrace:
1. base::table(attr.mat["id", ])
-- 5. Error: (unknown) (@test-renderer1-knit-print.R#100) ---------------------
Summary: NoSuchElement
Detail: An element could not be located on the page using the given search parameters.
class: org.openqa.selenium.NoSuchElementException
Further Details: run errorDetails method
Backtrace:
1. animint2:::get_elements("plot1top")
2. remDr$findElement("id", id)
3. RSelenium:::queryRD(...)
4. RSelenium:::checkStatus(resContent)
== testthat results ===========================================================
[ OK: 3 | SKIPPED: 0 | WARNINGS: 0 | FAILED: 5 ]
1. Failure: knit_print.animint renders five x axis titles (@test-renderer1-knit-print.R#26)
2. Failure: segments and breakpoints are rendered (@test-renderer1-knit-print.R#31)
3. Failure: segments and breakpoints are rendered (@test-renderer1-knit-print.R#33)
4. Error: svg id property is unique (@test-renderer1-knit-print.R#39)
5. Error: (unknown) (@test-renderer1-knit-print.R#100)
Error: testthat unit tests failed
>
@lazycipher
Copy link
Author

Generated HTML Code:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />




<title>My Rmd Document</title>

<script src="index_files/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="index_files/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="index_files/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="index_files/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="index_files/bootstrap-3.3.5/shim/respond.min.js"></script>
<script src="index_files/navigation-1.1/tabsets.js"></script>
<link href="index_files/highlightjs-9.12.0/default.css" rel="stylesheet" />
<script src="index_files/highlightjs-9.12.0/highlight.js"></script>

<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
 pre:not([class]) {
   background-color: white;
 }
</style>
<script type="text/javascript">
if (window.hljs) {
 hljs.configure({languages: []});
 hljs.initHighlightingOnLoad();
 if (document.readyState && document.readyState === "complete") {
   window.setTimeout(function() { hljs.initHighlighting(); }, 0);
 }
}
</script>



<style type="text/css">
h1 {
 font-size: 34px;
}
h1.title {
 font-size: 38px;
}
h2 {
 font-size: 30px;
}
h3 {
 font-size: 24px;
}
h4 {
 font-size: 18px;
}
h5 {
 font-size: 16px;
}
h6 {
 font-size: 12px;
}
.table th:not([align]) {
 text-align: left;
}
</style>




<style type = "text/css">
.main-container {
 max-width: 940px;
 margin-left: auto;
 margin-right: auto;
}
code {
 color: inherit;
 background-color: rgba(0, 0, 0, 0.04);
}
img {
 max-width:100%;
}
.tabbed-pane {
 padding-top: 12px;
}
.html-widget {
 margin-bottom: 20px;
}
button.code-folding-btn:focus {
 outline: none;
}
summary {
 display: list-item;
}
</style>



<!-- tabsets -->

<style type="text/css">
.tabset-dropdown > .nav-tabs {
 display: inline-table;
 max-height: 500px;
 min-height: 44px;
 overflow-y: auto;
 background: white;
 border: 1px solid #ddd;
 border-radius: 4px;
}

.tabset-dropdown > .nav-tabs > li.active:before {
 content: "�";
 font-family: 'Glyphicons Halflings';
 display: inline-block;
 padding: 10px;
 border-right: 1px solid #ddd;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
 content: "&#xe258;";
 border: none;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
 content: "�";
 font-family: 'Glyphicons Halflings';
 display: inline-block;
 padding: 10px;
 border-right: 1px solid #ddd;
}

.tabset-dropdown > .nav-tabs > li.active {
 display: block;
}

.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
 border: none;
 display: inline-block;
 border-radius: 4px;
 background-color: transparent;
}

.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
 display: block;
 float: none;
}

.tabset-dropdown > .nav-tabs > li {
 display: none;
}
</style>

<!-- code folding -->




</head>

<body>


<div class="container-fluid main-container">




<div class="fluid-row" id="header">



<h1 class="title toc-ignore">My Rmd Document</h1>

</div>


<pre><code>## list()</code></pre>
<pre class="r"><code>library(animint2)
dat &lt;- data.frame(x = 1:10, y = 1:10, label = rep(c(&quot;a178&quot;, &quot;b934&quot;), 5))
q2 &lt;- list(q = qplot(x, y, data = dat, colour = label, 
                    xlab = &quot;first plot with color legend&quot;))
structure(q2, class = &quot;animint&quot;)</code></pre>
<pre><code>## Saving animint in temporary directory; specify output directory using animint(out.dir=&quot;path/to/directory&quot;)</code></pre>
<pre><code>## opening a web browser with a file:// URL; if the web page is blank, try running
## if (!requireNamespace(&quot;servr&quot;)) install.packages(&quot;servr&quot;)
## servr::httd(&quot;C:/Users/imhim/AppData/Local/Temp/RtmpgHoa3W/file3fac661910f0&quot;)</code></pre>
<p>Clicking on the plot above should not affect the plot below.</p>
<pre class="r"><code>q1 &lt;- list(q = qplot(x, y, data = dat, colour = label, 
                    xlab = &quot;second plot with color legend&quot;))
structure(q1, class = &quot;animint&quot;)</code></pre>
<pre><code>## Saving animint in temporary directory; specify output directory using animint(out.dir=&quot;path/to/directory&quot;)</code></pre>
<pre><code>## opening a web browser with a file:// URL; if the web page is blank, try running
## if (!requireNamespace(&quot;servr&quot;)) install.packages(&quot;servr&quot;)
## servr::httd(&quot;C:/Users/imhim/AppData/Local/Temp/RtmpgHoa3W/file3fac40f24af5&quot;)</code></pre>
<p>The plot below has no interactive features.</p>
<pre class="r"><code>boring &lt;- list(q = qplot(rnorm(100), xlab = &quot;non-interactive plot&quot;))
structure(boring, class = &quot;animint&quot;)</code></pre>
<pre><code>## Saving animint in temporary directory; specify output directory using animint(out.dir=&quot;path/to/directory&quot;)</code></pre>
<pre><code>## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.</code></pre>
<pre><code>## opening a web browser with a file:// URL; if the web page is blank, try running
## if (!requireNamespace(&quot;servr&quot;)) install.packages(&quot;servr&quot;)
## servr::httd(&quot;C:/Users/imhim/AppData/Local/Temp/RtmpgHoa3W/file3facd2859e5&quot;)</code></pre>
<p>The next data viz consists of two plots, one of which should have common chunk data files.</p>
<pre class="r"><code>data(breakpoints)
only.error &lt;- subset(breakpoints$error,type==&quot;E&quot;)
only.segments &lt;- subset(only.error,bases.per.probe==bases.per.probe[1])
signal.colors &lt;- c(estimate=&quot;#0adb0a&quot;,
                  latent=&quot;#0098ef&quot;)
breakpointError &lt;- 
 list(signal=ggplot()+
        geom_point(aes(position, signal), showSelected=&quot;bases.per.probe&quot;,
                   data=breakpoints$signals)+
        geom_line(aes(position, signal), colour=signal.colors[[&quot;latent&quot;]],
                  data=breakpoints$imprecision)+
        geom_segment(aes(first.base, mean, xend=last.base, yend=mean),
                         showSelected=c(&quot;segments&quot;, &quot;bases.per.probe&quot;),
                     colour=signal.colors[[&quot;estimate&quot;]],
                     data=breakpoints$segments)+
        geom_vline(aes(xintercept=base),
                       showSelected=c(&quot;segments&quot;, &quot;bases.per.probe&quot;),
                   colour=signal.colors[[&quot;estimate&quot;]],
                   linetype=&quot;dashed&quot;,
                   data=breakpoints$breaks),
      error=ggplot()+
        geom_vline(aes(xintercept=segments),
                   clickSelects=&quot;segments&quot;,
                   data=only.segments, lwd=17, alpha=1/2)+
        geom_line(aes(segments, error, group=bases.per.probe),
                  clickSelects=&quot;bases.per.probe&quot;,
                  data=only.error, lwd=4),
      first=list(segments=6))
structure(breakpointError, class=&quot;animint&quot;)</code></pre>
<pre><code>## Saving animint in temporary directory; specify output directory using animint(out.dir=&quot;path/to/directory&quot;)</code></pre>
<pre><code>## opening a web browser with a file:// URL; if the web page is blank, try running
## if (!requireNamespace(&quot;servr&quot;)) install.packages(&quot;servr&quot;)
## servr::httd(&quot;C:/Users/imhim/AppData/Local/Temp/RtmpgHoa3W/file3fac4cd5286&quot;)</code></pre>




</div>

<script>

// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
 $('tr.header').parent('thead').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
 bootstrapStylePandocTables();
});


</script>

<!-- tabsets -->

<script>
$(document).ready(function () {
 window.buildTabsets("TOC");
});

$(document).ready(function () {
 $('.tabset-dropdown > .nav-tabs > li').click(function () {
   $(this).parent().toggleClass('nav-tabs-open')
 });
});
</script>

<!-- code folding -->


<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
 (function () {
   var script = document.createElement("script");
   script.type = "text/javascript";
   script.src  = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
   document.getElementsByTagName("head")[0].appendChild(script);
 })();
</script>

</body>
</html>

@lazycipher
Copy link
Author

Rendered UI from the above HTML Code:
screencapture-localhost-4848-animint-htmltest-2020-06-06-13_27_08

@lazycipher
Copy link
Author

sessionInfo() returns:

> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_India.1252  LC_CTYPE=English_India.1252    LC_MONETARY=English_India.1252 LC_NUMERIC=C                  
[5] LC_TIME=English_India.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] knitr_1.28        XML_3.99-0.3      RSelenium_1.7.7   animint2_2020.3.2 testthat_2.3.2   

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6     compiler_4.0.0   plyr_1.8.6       bitops_1.0-6     tools_4.0.0      pkgload_1.1.0    digest_0.6.25    jsonlite_1.6.1  
 [9] evaluate_0.14    lifecycle_0.2.0  gtable_0.3.0     rlang_0.4.6      cli_2.0.2        rstudioapi_0.11  curl_4.3         yaml_2.2.1      
[17] xfun_0.14        binman_0.1.1     stringr_1.4.0    withr_2.2.0      httr_1.4.1       xml2_1.3.2       desc_1.2.0       askpass_1.1     
[25] caTools_1.18.0   rappdirs_0.3.1   rprojroot_1.3-2  grid_4.0.0       glue_1.4.1       R6_2.4.1         processx_3.4.2   fansi_0.4.1     
[33] rmarkdown_2.2    RJSONIO_1.3-1.4  farver_2.0.3     semver_0.2.0     magrittr_1.5     backports_1.1.7  scales_1.1.1     ps_1.3.3        
[41] htmltools_0.4.0  assertthat_0.2.1 colorspace_1.4-1 labeling_0.3     stringi_1.4.6    openssl_1.4.1    munsell_0.5.0    crayon_1.3.4    
[49] wdman_0.2.5     
> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment