-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use `rmarkdown::render_site` to create GitHub docs.
- Loading branch information
Showing
101 changed files
with
20,787 additions
and
2,772 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,10 @@ Package: summarywidget | |
Title: Display Summary Statistics from Linked Data | ||
Version: 0.0.0.9000 | ||
Authors@R: person("Kent", "Johnson", email = "[email protected]", role = c("aut", "cre")) | ||
Description: summarywidget displays a single statistic derived from a linked table. It's primary use is with the crosstalk package. Used with crosstalk, a summarywidget displays a value which updates as the data selection changes. | ||
Description: SummaryWidget displays a single statistic derived from a linked table. | ||
It's primary use is with the crosstalk package. | ||
Used with crosstalk, a summarywidget displays a value which updates | ||
as the data selection changes. | ||
URL: https://github.com/kent37/summarywidget | ||
BugReports: https://github.com/kent37/summarywidget/issues | ||
Depends: R (>= 3.3.2) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: "summaryWidget" | ||
navbar: | ||
title: "SummaryWidget" | ||
type: inverse | ||
left: | ||
- text: "Home" | ||
href: index.html | ||
- text: "Using SummaryWidget" | ||
href: using.html | ||
- text: "Extended Example" | ||
href: example.html | ||
right: | ||
- icon: fa-github fa-lg | ||
href: https://github.com/kent37/summarywidget | ||
output: | ||
html_document: | ||
theme: spacelab | ||
highlight: textmate | ||
toc_depth: 3 | ||
toc_float: true | ||
output_dir: . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,44 @@ | ||
--- | ||
title: "SummaryWidget" | ||
output: | ||
flexdashboard::flex_dashboard: | ||
orientation: columns | ||
vertical_layout: scroll | ||
theme: spacelab | ||
navbar: | ||
- { icon: "fa-github", href: "https://github.com/kent37/summarywidget", align: right } | ||
--- | ||
|
||
```{r setup, include=FALSE} | ||
library(flexdashboard) | ||
knitr::opts_chunk$set(echo = TRUE) | ||
``` | ||
|
||
Using | ||
===================================== | ||
|
||
SummaryWidget is an [htmlwidget](http://www.htmlwidgets.org) which works with | ||
[crosstalk](https://rstudio.github.io/crosstalk/index.html) to display a single | ||
summary statistic which updates when the `crosstalk` selection changes. A SummaryWidget can display the count, sum or mean of one column of the selected data. | ||
It can also have a fixed filter that selects a subset of the full dataset. | ||
|
||
#### Simple example | ||
|
||
This code uses `crosstalk` to select from the `mtcars` database and | ||
a single `summarywidget` to report the number of cars selected. | ||
|
||
#### Install `crosstalk` and `summarywidget` | ||
|
||
``` | ||
devtools::install_github("rstudio/crosstalk") | ||
devtools::install_github("kent37/summarywidget") | ||
``` | ||
|
||
#### Load libraries | ||
|
||
```{r example1} | ||
library(crosstalk) | ||
library(DT) | ||
library(summarywidget) | ||
``` | ||
#### Create a crosstalk::SharedData object | ||
|
||
```{r} | ||
shared_mtcars = SharedData$new(mtcars) | ||
shared_mtcars = SharedData$new(mtcars[,c("mpg", "cyl", "hp", "am")]) | ||
``` | ||
|
||
#### Create a crosstalk checkbox | ||
SummaryWidget is an [HTML widget](http://www.htmlwidgets.org) which works with | ||
[Crosstalk](https://rstudio.github.io/crosstalk/index.html) to display a single | ||
summary statistic. The statistic updates when the Crosstalk selection changes. A SummaryWidget can display the count, sum or mean of one column of selected data. | ||
It can also have a fixed filter that selects a subset of the full dataset. | ||
|
||
Click the checkboxes and see the count change below. | ||
Try the example below. Click the checkboxes, manipulate the slider and | ||
click rows in the data table. Watch the summary text update as the data selection changes. | ||
The summary text uses four `summarywidget` instances to show four different summary statistics. | ||
|
||
```{r} | ||
filter_checkbox("cyl", "Cylinders", shared_mtcars, ~cyl, inline = TRUE) | ||
``` | ||
----- | ||
|
||
#### Show the number of cars selected | ||
<big>You have selected **`r summarywidget(shared_mtcars)`** cars with an average mpg of | ||
**`r summarywidget(shared_mtcars, 'mean', 'mpg', digits=1)`**. | ||
The **`r summarywidget(shared_mtcars, selection=~am==0)`** cars with automatic | ||
transmission have an average mpg of | ||
**`r summarywidget(shared_mtcars, 'mean', 'mpg', selection=~am==0, digits=1)`**.</big> | ||
|
||
The default is to show a count of selected items. | ||
|
||
```{r} | ||
summarywidget(shared_mtcars) | ||
```{r example, echo=FALSE} | ||
bscols(widths = c(3,NA), | ||
list( | ||
filter_checkbox("cyl", "Cylinders", shared_mtcars, ~cyl, inline = TRUE), | ||
filter_slider("hp", "Horsepower", shared_mtcars, ~hp, width = "100%") | ||
), | ||
datatable(shared_mtcars, width=600, height=300, | ||
options=list(pageLength=5, dom='tp')) | ||
) | ||
``` | ||
|
||
Example | ||
===================================== | ||
|
||
### Chart 1 | ||
|
||
### Next steps | ||
|
||
Read the [Using SummaryWidget](using.html) guide. See the [Extended Example](example.html) for another use. |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.