An open API service indexing awesome lists of open source software.

https://github.com/jumpingrivers/pier


https://github.com/jumpingrivers/pier

Last synced: 8 months ago
JSON representation

Awesome Lists containing this project

README

          

---
output:
md_document:
variant: markdown_github
editor_options:
chunk_output_type: console
---

[![R-CMD-check](https://github.com/jumpingrivers/pieR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jumpingrivers/pieR/actions/workflows/R-CMD-check.yaml)

```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```

# pieR

A utility package for creating d3 pie charts based on the RStudio js tutorials.

## Installation

You can install **pieR** from GitHub with:

```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("jumpingrivers/pieR")
```

## Example

A couple of basic examples of the `pie()` function:

```{r example1, results="hide", message=FALSE}
library("pieR")
pie(1:5)
pie(c(5, 5, 5))
```

# A basic Shiny example

```{r, eval = TRUE}
## Only run this in interactive R sessions
if(interactive()) {
library("shiny")
ui = fluidPage(
titlePanel("Pie Example!"),
sidebarLayout(
sidebarPanel(
sliderInput("obs",
"Generate n random Numbers",
min = 2,
max = 10,
value = 5)
),
mainPanel(
pieOutput("piePlot"),
textOutput("randNo")
)
)
)
# Define the server code
server = function(input, output) {
numbers = reactive(round(runif(input$obs, 1, 10),0))
output$piePlot = renderPie({
pie(numbers())
})
output$randNo = renderText({
numbers()
})
}
shinyApp(ui = ui, server = server)
}
```