A utility package for creating d3 pie charts based on the RStudio js tutorials.
You can install pieR from GitHub with:
# install.packages("devtools")
devtools::install_github("jumpingrivers/pieR")
A couple of basic examples of the pie()
function:
library("pieR")
pie(1:5)
pie(c(5, 5, 5))
## 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)
}