Skip to contents

Create a linked plotlyof the global data- and attribution- spaces. Typically consumed directly by shiny app.

Usage

radial_cheem_tour(
  cheem_ls,
  basis,
  manip_var,
  primary_obs = NULL,
  comparison_obs = NULL,
  do_add_pcp_segments = TRUE,
  pcp_shape = c(3, 142, 124),
  angle = 0.15,
  row_index = NULL,
  inc_var_nms = NULL,
  do_center_frame = TRUE,
  do_add_residual = FALSE
)

Arguments

cheem_ls

A return from cheem_ls(), a list of data frames.

basis

A 1D projection basis, typically a return of sug_basis().

manip_var

The , number of the manipulation variable.

primary_obs

The rownumber of the primary observation. Its local attribution becomes the 1d projection basis, and the point it highlighted as a dashed line. Defaults to NULL, no primary observation highlighted.

comparison_obs

The rownumber of the comparison observation. Point is highlighted as a dotted line. Defaults to NULL, no comparison observation highlighted.

do_add_pcp_segments

Logical, whether or not to add parallel coordinate line segments to the basis display.

pcp_shape

The number of the shape character to add. Expects 3, 142, or 124, '+', '|' in plotly, and '|' in gganimate, respectively. Defaults to 3, '+' in either output.

angle

The step size between interpolated frames, in radians. Defaults to .15.

row_index

Numeric index of selected observations. Defaults to TRUE; 1:n.

inc_var_nms

A vector of the names of the variables to include in the projection.

do_center_frame

Whether or not to scale by standard deviations away from the mean within each frame or not. Defaults to TRUE, helping to keep the animation centered.

do_add_residual

Whether of not to add a facet with a fixed y on residual. Doing so may cause issues with animation. Defaults to FALSE.

Value

ggtour (ggplot2 object with frame info) animation frames of a radial tour manipulating the contribution of a selected tour. Animated with spinifex::animate_* functions.

See also

run_app()

Other cheem consumers: global_view_legwork(), global_view(), run_app()

Examples

library(cheem)

## Regression setup:
dat  <- amesHousing2018_NorthAmes
X    <- dat[, 1:9]
Y    <- dat$SalePrice
clas <- dat$SubclassMS

## radial_cheem_tour()
ames_rf_chm <- cheem_ls(X, Y, ames_rf_shap, ames_rf_pred, clas,
                        label = "North Ames, RF, SHAP")
bas <- sug_basis(ames_rf_shap, 1)
mv  <- sug_manip_var(ames_rf_shap, 1, 2)
ggt <- radial_cheem_tour(ames_rf_chm, basis = bas, manip_var = mv)
if(interactive()){
  ## As a plotly html widget
  spinifex::animate_plotly(ggt)
  
  ## As a gganimation
  spinifex::animate_gganimate(ggt, render = gganimate::av_renderer())
}
## Also used in: ?run_app()