sunburst: Quickly get a D3 js sunburst

Description Usage Arguments Bugs Examples

View source: R/sunburst.R

Description

This function will take 4 columns of data, format the data, then feed it to sunburstR where it will be converted into a D3 plot.

Usage

1
2
sunburst(dataframe, id, linename, linenumber, n_common = 5,
  return_data = F, legend_width = 300)

Arguments

dataframe

the dataframe holding the data

id

grouping variable that links the long data. Most likely patient id.

linename

The name of the line - or whatever goes in the bars

linenumber

A column with the numeric line number.

n_common

The n most common treatments you want to include. Others will go into no treatment or other.

return_data

FALSE by default. If true, it will return the formatted data for you to pass to the plotting function yourself.

legend_width

Width of the legend in pixels. This will likely need tweaking.

Bugs

If you find an issue, post it here and we'll try and fix it: http://go.roche.com/RochePlotissue

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
## Not run: 
          ##### Get data from flatiron ##################
             library(dplyr)


             # data valid today
             valid_date <- Sys.Date()

             # If on Windows, life is no fun
             if (Sys.info()[["sysname"]] == "Windows"){
               Sys.setenv(JAVA_HOME="")  # for java - go to 64bit
             }

             # connect to data
             tdRWDSconnect(
               datalab = FALSE,
               type = "teradataR"
             )

             line.of.therapy <- tdRWDSquery(paste0(
               "
               SELECT
               patientid
               ,LineName
               ,LineNumber
               ,IsMaintenanceTherapy
               FROM rwd_vdm_flatiron.v_cll_lineoftherapy
               WHERE
               VALID_START <= CAST('",paste0(valid_date," 00:00:00"),"' AS TIMESTAMP) AND
               VALID_END >= CAST('",paste0(valid_date," 00:00:00"),"' AS TIMESTAMP)
               ;"
             )) %>%
               filter(
                 # just do lines 0 to 3
                 LineNumber < 4 &
                   # and ignore maintenence
                   IsMaintenanceTherapy == "False"
               )

             ##### Use function ##################

             sunburst(
               dataframe = line.of.therapy,
               id = "PatientID",
               linename = "LineName",
               linenumber = "LineNumber",
               n_common = 3,
               legend_width = 300
             )

          
## End(Not run)

epijim/PharmaPlots documentation built on Nov. 4, 2019, 11:54 a.m.