library(tourr)
data("flea", package = "tourr")
data <- flea[1:6]
clusters <- as.numeric(flea$species)
flea_subspecies <- unique(flea$species)
feature_names <- colnames(data)
guided_tour_history <- tourr::save_history(data,
tour_path = tourr::guided_tour(holes())
)
grand_tour_history_1d <- tourr::save_history(data,
tour_path = tourr::grand_tour(d = 1)
)
half_range <- max(sqrt(rowSums(data^2)))
obj1 <- list(type = "2d_tour", obj = guided_tour_history)
obj2 <- list(type = "1d_tour", obj = grand_tour_history_1d)
obj3 <- list(type = "scatter", obj = c("tars1", "tars2"))
obj4 <- list(type = "hist", obj = "head")
if (check_venv()){
init_env(env_name = "r-lionfish", virtual_env = "virtual_env")
} else if (check_conda_env()){
init_env(env_name = "r-lionfish", virtual_env = "anaconda")
}
if (interactive()){
interactive_tour(
data = data,
plot_objects = list(obj1, obj2, obj3, obj4),
feature_names = feature_names,
half_range = half_range,
n_plot_cols = 2,
preselection = clusters,
preselection_names = flea_subspecies,
n_subsets = 5,
display_size = 5
)
}
Run the code above in your browser using DataLab