as_d3_data: Transform the 'de' object to JSON data for D3 visualization.

Description Usage Arguments Details Value Author(s) Examples

Description

The returned object is a JSON representation of a JavaScript object having components 'mtd', 'trial' and 'ds' – the last of which stands for 'dose-survival'.

Usage

1
2
## S3 method for class 'de'
as_d3_data(x, ...)

Arguments

x

The 'de' object to be transformed

...

Unused; included to match signature of generic method

Details

The (unhelpful) default behavior of function r2d3 is to effect this transformation so as to reduce the size of transmitted data, then restore the original form upon receipt using JavaScript method HTMLWidgets.dataframeToD3(). See https://rstudio.github.io/r2d3/articles/data_conversion.html.

Value

The returned value is a JSON string corresponding to a list of data frames:

mtd

Data frame with columns c('id','mtd')

trial

Data frame with 'id', 'period', 'dose', 'dlt'.)

ds

Data frame with columns 'period','surv','lower','upper','dose'.

Author(s)

David C. Norris

Examples

1
2
3
4
5
6
7
8
9
library(DTAT)
de <- de.sim(testing=TRUE)
data <- as_d3_data(de)
## Read 'data' back into a list and check a few things
check <- jsonlite::fromJSON(data)
stopifnot(max(abs(attr(de,'mtd') - check$mtd)) < 1e-4)
stopifnot(max(abs(attr(de,'doses') - check$doses)) < 1e-4)
stopifnot(max(abs(attr(de,'mtd_quantiles') - check$mtd_quantiles)) < 1e-4)
stopifnot(all(de[[length(de)]] - check$trial == 0))

dcnorris/DTAT documentation built on May 7, 2019, 10:45 p.m.