Description Usage Arguments Value Examples
Create a dynamic image object containing plots
1 2 3 |
sel_id |
The id of the selector used to choose options |
options |
A named list of plot objects, with the number of options and names of options matching those used in the selector object. |
fig_output_dir |
Filepath of the directory where plots should be saved. If unspecified, the default output directory for the current knitr chunk will be used. |
dev |
The device to be used for saving the plots ('png', 'jpg', 'pdf', etc.) |
fig.width |
Plot width in inches. This can be a single number or a numeric vector matching the number of options. |
fig.height |
Plot length in inches. This can be a single number or a numeric vector matching the number of options. |
dpi |
The resolution of the image. |
embed |
A logical vector for whether images should be embedded directly into the HTML code as base64 strings. If FALSE, image files are referred to via links in the HTML code. |
Raw HTML representing the image object. If 'embed = FALSE', image files are created and saved in a directory determined by 'fig_output_dir'.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ## Not run:
```{r add_js, results='asis'}
library(selr)
add_javascript()
```
```{r add_selector, results='asis'}
add_selector(
sel_id = "Dataset",
options = list("Option_1" = "iris",
"Option_2" = "mtcars")
)
```
```{r create_plots}
iris_plot <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length,
color = Species)) +
geom_point()
mtcars_plot <- ggplot(mtcars, aes(x = wt, y = mpg,
color = factor(gear))) +
geom_point()
```
```{r image_selector, results='asis'}
sel_image(
sel_id = "Dataset",
options = list("Option_1" = iris_plot,
"Option_2" = mtcars_plot),
fig.width = 6, fig.height = 3.25, dpi = 450,
embed = TRUE
)
```
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.