Typically called by array2af(). An array of projections, the radial tour of the manip_var, which is rotated from phi's starting position to phi_max, to phi_min, and back to the start position.

manual_tour(
  basis,
  manip_var,
  theta = NULL,
  phi_min = 0,
  phi_max = pi/2,
  data = NULL
)

Arguments

basis

A (p, d) orthonormal numeric matrix. The linear combination the original variables contribute to projection space. Defaults to NULL, generating a random basis.

manip_var

Integer column number or string exact column name of the. variable to manipulate. Required, no default.

theta

Angle in radians of "in-plane" rotation, on the xy plane of the reference frame. Defaults to theta of the basis for a radial tour.

phi_min

Minimum value phi should move to. Phi is angle in radians of the "out-of-plane" rotation, the z-axis of the reference frame. Required, defaults to 0.

phi_max

Maximum value phi should move to. Phi is angle in radians of the "out-of-plane" rotation, the z-axis of the reference frame. Required, defaults to pi/2.

data

Optionally attach data to the basis path.

Value

A (p, d, 4) history_array of the radial tour. The bases set for phi_start, phi_min, phi_max, and back to phi_start.

See also

Other manual tour adjacent functions: create_manip_space(), interpolate_manual_tour(), manip_var_of(), rotate_manip_space()

Examples

## Setup
dat_std <- scale_sd(wine[, 2:6])
clas <- wine$Type
bas <- basis_pca(dat_std)
mv <- manip_var_of(bas)
manual_tour(basis = bas, manip_var = mv)
#> , , 1
#> 
#>                   PC1        PC2
#> Alcohol    0.09339195  0.6578986
#> Malic      0.42873573 -0.1335841
#> Ash        0.65072062  0.1843494
#> Alcalinity 0.57844161 -0.4342966
#> Magnesium  0.22233218  0.5715999
#> 
#> attr(,"manip_var")
#> Alcohol 
#>       4 
#> attr(,"theta")
#> [1] -0.6440158
#> attr(,"phi_start")
#> [1] 0.7621816
#> attr(,"phi_min")
#> [1] 0
#> attr(,"phi_max")
#> [1] 1.570796

## All arguments
manual_tour(basis = bas, manip_var = mv,
            theta = pi / 2, phi_min = pi / 16, phi_max = pi)
#> , , 1
#> 
#>                   PC1        PC2
#> Alcohol    0.09339195  0.6578986
#> Malic      0.42873573 -0.1335841
#> Ash        0.65072062  0.1843494
#> Alcalinity 0.57844161 -0.4342966
#> Magnesium  0.22233218  0.5715999
#> 
#> attr(,"manip_var")
#> Alcohol 
#>       4 
#> attr(,"theta")
#> [1] 1.570796
#> attr(,"phi_start")
#> [1] 0.7621816
#> attr(,"phi_min")
#> [1] 0.1963495
#> attr(,"phi_max")
#> [1] 3.141593

## d = 1 case
bas1d <- basis_pca(dat_std, d = 1)
mv <- manip_var_of(bas1d)
manual_tour(basis = bas1d, manip_var = mv)
#> , , 1
#> 
#>                   PC1
#> Alcohol    0.09339195
#> Malic      0.42873573
#> Ash        0.65072062
#> Alcalinity 0.57844161
#> Magnesium  0.22233218
#> 
#> attr(,"manip_var")
#> Alcohol 
#>       3 
#> attr(,"theta")
#> [1] NA
#> attr(,"phi_start")
#> [1] 0.8622632
#> attr(,"phi_min")
#> [1] 0
#> attr(,"phi_max")
#> [1] 1.570796

## Animating with ggtour() & proto_*
mt <- manual_tour(basis = bas, manip_var = mv)
ggt <- ggtour(mt, dat_std, angle = .2) +
    proto_origin() +
    proto_point(list(color = clas, shape = clas)) +
    proto_basis()
# \donttest{
animate_plotly(ggt)
# }