library(spinifex)
dat <- scale_sd(wine[, 2:6])
clas <- wine$Type
bas <- basis_pca(dat)
mv <- manip_var_of(bas)
manual_tour(basis = bas, manip_var = mv)
## All arguments
manual_tour(basis = bas, manip_var = mv,
theta = pi / 2, phi_min = pi / 16, phi_max = pi)
## Animating with ggtour() & proto_* (d = 2 case)
mt <- manual_tour(basis = bas, manip_var = mv)
ggt <- ggtour(mt, dat, angle = .2) +
proto_origin() +
proto_point(list(color = clas, shape = clas)) +
proto_basis()
# \donttest{
animate_plotly(ggt)
# }
## d = 1 case
## basis could be 1- or 2D; protos_* only use 1st column
mv <- manip_var_of(bas)
mt <- manual_tour(basis = bas, manip_var = mv)
ggt <- ggtour(mt, dat, angle = .3) +
proto_density(aes_args = list(color = clas, fill = clas)) +
proto_basis1d() +
proto_origin1d()
# \donttest{
animate_plotly(ggt)
# }
## Bring your own basis
bas <- matrix(rnorm(2 * ncol(dat)), ncol = 2)
bas <- orthonormalise(bas) ## manual_tour warns if basis isn't orthonormal
mt <- manual_tour(basis = bas, manip_var = 1)
ggt <- ggtour(mt, dat, angle = .2) +
proto_default(aes_args = list(color = clas, shape = clas))
# \donttest{
animate_plotly(ggt)
# }
Run the code above in your browser using DataLab