library(knitr) # Calling knit_meta() here is just a safety protocol. # knit_print.animint uses knitr's meta-data to efficiently place JS scripts. # If this meta-data isn't clear when a document is knit, the result won't be rendered properly knit_meta()
library(animint2) dat <- data.frame(x = 1:10, y = 1:10, label = rep(c("a178", "b934"), 5)) animint(q = qplot( x, y, data = dat, colour = label, xlab = "first plot with color legend"))
Clicking on the plot above should not affect the plot below.
animint(q = qplot( x, y, data = dat, colour = label, xlab = "second plot with color legend"))
The plot below has no interactive features.
animint(q = qplot(rnorm(100), xlab = "non-interactive plot"))
The next data viz consists of two plots, one of which should have common chunk data files.
data(breakpoints) only.error <- subset(breakpoints$error,type=="E") only.segments <- subset(only.error,bases.per.probe==bases.per.probe[1]) signal.colors <- c(estimate="#0adb0a", latent="#0098ef") animint( signal=ggplot()+ geom_point(aes(position, signal), showSelected="bases.per.probe", data=breakpoints$signals)+ geom_line(aes(position, signal), colour=signal.colors[["latent"]], data=breakpoints$imprecision)+ geom_segment(aes(first.base, mean, xend=last.base, yend=mean), showSelected=c("segments", "bases.per.probe"), colour=signal.colors[["estimate"]], data=breakpoints$segments)+ geom_vline(aes(xintercept=base), showSelected=c("segments", "bases.per.probe"), colour=signal.colors[["estimate"]], linetype="dashed", data=breakpoints$breaks), error=ggplot()+ geom_vline(aes(xintercept=segments), clickSelects="segments", data=only.segments, lwd=17, alpha=1/2)+ geom_line(aes(segments, error, group=bases.per.probe), clickSelects="bases.per.probe", data=only.error, lwd=4), first=list(segments=6))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.