Skip to content

Commit

Permalink
Much better documentation
Browse files Browse the repository at this point in the history
Use `rmarkdown::render_site` to create GitHub docs.
  • Loading branch information
kent37 committed Mar 24, 2017
1 parent defd5f2 commit 04c0863
Show file tree
Hide file tree
Showing 101 changed files with 20,787 additions and 2,772 deletions.
5 changes: 4 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/summarywidget.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Widget that shows a single summary statistic
#' Show a single summary statistic in a widget
#'
#' `summarywidget` displays a single statistic derived from a linked table.
#' It's primary use is with the `crosstalk` package. Used with `crosstalk`,
Expand Down
21 changes: 21 additions & 0 deletions docs/_site.yml
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: .
80 changes: 27 additions & 53 deletions docs/index.Rmd
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.
2,849 changes: 224 additions & 2,625 deletions docs/index.html

Large diffs are not rendered by default.

Loading

0 comments on commit 04c0863

Please sign in to comment.