append_fixed_y {spinifex}R Documentation

Append a fixed vertical height

Description

Adds/overwrites the y of the projected data. Usefully for 1D projections and appending information related to, but independent from the projection; model predictions or residuals for instance. Wants to be called early so that the following proto calls adopt the changes.

Usage

append_fixed_y(fixed_y)

Arguments

fixed_y

Vector of length of the data, values to fix vertical height. Typically related to but not an explanatory variable, for instance, predicted Y, or residuals.

See Also

Other ggtour proto functions: facet_wrap_tour(), ggtour(), proto_basis(), proto_default(), proto_density(), proto_density2d(), proto_hex(), proto_highlight(), proto_hline0(), proto_origin(), proto_point(), proto_text()

Examples

library(spinifex)
dat     <- scale_sd(penguins_na.rm[, 1:4])
clas    <- penguins_na.rm$species
bas     <- basis_pca(dat)
mv      <- manip_var_of(bas)
mt_path <- manual_tour(bas, manip_var = mv)

# Fixed y height with related information, independent of a 1D tour 
# _eg_ predictions or residuals.
message("don't forget to scale your fixed_y.")
dummy_y <- scale_sd(as.integer(clas) + rnorm(nrow(dat), 0, .5))
gt_path <- save_history(dat, grand_tour(d = 1), max_bases = 5)

message("append_fixed_y wants to be called early so other proto's adopt the fixed_y.")
ggt <- ggtour(gt_path, dat, angle = .3) +
  append_fixed_y(fixed_y = dummy_y) + ## insert/overwrites vertical values.
  proto_point(list(fill = clas, color = clas)) +
  proto_basis1d() +
  proto_origin()

animate_plotly(ggt)


[Package spinifex version 0.3.7.0 Index]