Skip to content

2005m/dcr

 
 

Repository files navigation

Introduction

Dc.js and crossfilter are useful for constructing interactive visualizations and exploratory analysis. This project integrates their features and capabilities into the Shiny. This package is still in the early stages of development, so use with caution.

Installation

if (!require(devtools)) install.packages("devtools")
devtools:::install_github("massmutual/dcr")

Examples

  • Input binding example (need dplyr package installed)
if (!require(dplyr)) install.packages("dplyr")
shiny::runGitHub("massmutual/dcr", subdir = "inst/example/input_binding")
  • Stock example. To run this example we need to install R packages quantmod, dplyr and lubridate
if (!require(dplyr)) install.packages("dplyr")
if (!require(quantmod)) install.packages("quantmod")
if (!require(lubridate)) install.packages("lubridate")

shiny::runGitHub("massmutual/dcr", subdir = "inst/example/stocks")

Usage

#We will use the mtcars data to make some simple charts
library(dcr)

#create chart object
mydcr <- dcr(mtcars)

#pie chart
chart1 <- dcrchart("pieChart", "chart1", "cyl", reduceCount(), width = 250, height = 250)

#line chart
chart2 <- dcrchart("lineChart", "chart2", "mpg", reduceMean("wt"), width = 400, height = 250,
                   xAxisLabel = "Gear", yAxisLabel = "Average Weight")


#row chart
chart3 <- dcrchart("rowChart", "chart3", "carb", reduceCount(), width = 300, height = 250)

#view the charts
mydcr + chart1 + chart2 + chart3

#Function Calls#

Create empty chart object with data##

###dcr(data)###

##Function function definition to create a chart to add to chart object## ###dcrchart(type, id, dimension, reduce, width, height, ...) ###

  • type: chart type such as pieChart, barChart
  • id: div id to display in the web page (layout divs in ui.R in shiny for each chart to display in)
  • dimension: dimension (which variable to group with)
  • reduce: how records are reduced for each group of dimension (reduceCount() to count number of obs, reduceSum(y) to sum up values of y)
  • width: chart width
  • height: chart height
  • ...: additional chart arguments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 50.0%
  • JavaScript 42.8%
  • R 6.6%
  • CSS 0.6%