From 9abf8fb86d5cb99ba87d94eee41644df18aa86c8 Mon Sep 17 00:00:00 2001 From: olivroy <52606734+olivroy@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:24:13 -0500 Subject: [PATCH 1/8] Add website to DESCRIPTION --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 598e39c8..f2c9364f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -37,7 +37,7 @@ Suggests: plotly License: MIT + file LICENSE LazyData: true -URL: https://github.com/ggobi/tourr +URL: https://github.com/ggobi/tourr, https://ggobi.github.io/tourr/ BugReports: https://github.com/ggobi/tourr/issues RoxygenNote: 7.2.3 Encoding: UTF-8 From 94b35816ba76a7885db61489fcf1c8258164dc4d Mon Sep 17 00:00:00 2001 From: dicook Date: Wed, 26 Jun 2024 00:23:45 +1000 Subject: [PATCH 2/8] only change to norm_bin docus --- man/anomaly_index.Rd | 12 +++++++ man/guided_anomaly_tour.Rd | 67 ++++++++++++++++++++++++++++++++++++++ man/mahal_dist.Rd | 18 ++++++++++ man/norm_bin.Rd | 4 +-- 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 man/anomaly_index.Rd create mode 100644 man/guided_anomaly_tour.Rd create mode 100644 man/mahal_dist.Rd diff --git a/man/anomaly_index.Rd b/man/anomaly_index.Rd new file mode 100644 index 00000000..299c5b01 --- /dev/null +++ b/man/anomaly_index.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/anomaly-pursuit.r +\name{anomaly_index} +\alias{anomaly_index} +\title{Anomaly index.} +\usage{ +anomaly_index() +} +\description{ +Calculates an index that looks for the best projection of +observations that are outside a pre-determined p-D ellipse. +} diff --git a/man/guided_anomaly_tour.Rd b/man/guided_anomaly_tour.Rd new file mode 100644 index 00000000..a9e81f27 --- /dev/null +++ b/man/guided_anomaly_tour.Rd @@ -0,0 +1,67 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tour-guided-anomaly.r +\name{guided_anomaly_tour} +\alias{guided_anomaly_tour} +\title{A guided anomaly tour path.} +\usage{ +guided_anomaly_tour( + index_f, + d = 2, + alpha = 0.5, + cooling = 0.99, + max.tries = 25, + max.i = Inf, + ellipse, + ellc = NULL, + ellmu = NULL, + search_f = search_geodesic, + ... +) +} +\arguments{ +\item{index_f}{the section pursuit index function to optimise. The function +needs to take two arguments, the projected data, indexes of anomalies.} + +\item{d}{target dimensionality} + +\item{alpha}{the initial size of the search window, in radians} + +\item{cooling}{the amount the size of the search window should be adjusted +by after each step} + +\item{max.tries}{the maximum number of unsuccessful attempts to find +a better projection before giving up} + +\item{max.i}{the maximum index value, stop search if a larger value is found} + +\item{ellipse}{pxp variance-covariance matrix defining ellipse, default NULL. +Useful for comparing data with some hypothesized null.} + +\item{ellc}{This can be considered the equivalent of a critical value, used to +scale the ellipse larger or smaller to capture more or fewer anomalies. Default 3.} + +\item{ellmu}{This is the centre of the ellipse corresponding to the mean of the +normal population. Default vector of 0's} + +\item{search_f}{the search strategy to use} + +\item{...}{arguments sent to the search_f} +} +\description{ +The guided anomaly tour is a variation of the guided tour that is +using an ellipse to determine anomalies on which to select target planes. +} +\details{ +Usually, you will not call this function directly, but will pass it to +a method that works with tour paths like \code{\link{animate_slice}}, +\code{\link{save_history}} or \code{\link{render}}. +} +\examples{ +animate_xy(flea[, 1:6], guided_anomaly_tour(anomaly_index(), + ellipse=cov(flea[,1:6])), ellipse=cov(flea[,1:6]), axes="off") +} +\seealso{ +\code{\link{slice_index}} for an example of an index functions. +\code{\link{search_geodesic}}, \code{\link{search_better}}, + \code{\link{search_better_random}} for different search strategies +} diff --git a/man/mahal_dist.Rd b/man/mahal_dist.Rd new file mode 100644 index 00000000..7a67a42b --- /dev/null +++ b/man/mahal_dist.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/linear-algebra.r +\name{mahal_dist} +\alias{mahal_dist} +\title{Calculate the Mahalanobis distance between points and center.} +\usage{ +mahal_dist(x, vc) +} +\arguments{ +\item{x}{matrix of data} + +\item{vc}{pre-determined variance-covariance matrix} +} +\description{ +Computes the Mahalanobis distance using a provided variance-covariance +matrix of observations from 0. +} +\keyword{algebra} diff --git a/man/norm_bin.Rd b/man/norm_bin.Rd index 390c2045..1a7376f9 100644 --- a/man/norm_bin.Rd +++ b/man/norm_bin.Rd @@ -14,11 +14,11 @@ norm_kol(nr) } \description{ Compares the similarity between the projected distribution and a normal distribution. -\itemize{ +} +\details{ \item norm_bin: compares the count in 100 histogram bins \item norm_kol: compares the cdf based on the Kolmogorov–Smirnov test (KS test) } -} \examples{ # manually compute the norm_kol index # create the index function From b34d651a885f2829683af5622bc4a928c7c9537f Mon Sep 17 00:00:00 2001 From: dicook Date: Thu, 4 Jul 2024 18:32:42 +1000 Subject: [PATCH 3/8] documentation changes --- DESCRIPTION | 2 +- R/tour-guided-anomaly.r | 2 +- man/guided_anomaly_tour.Rd | 2 +- man/norm_bin.Rd | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ded28be4..9f3f8ca9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -39,6 +39,6 @@ License: MIT + file LICENSE LazyData: true URL: https://github.com/ggobi/tourr BugReports: https://github.com/ggobi/tourr/issues -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Encoding: UTF-8 VignetteBuilder: knitr diff --git a/R/tour-guided-anomaly.r b/R/tour-guided-anomaly.r index 0271b93d..914806a5 100644 --- a/R/tour-guided-anomaly.r +++ b/R/tour-guided-anomaly.r @@ -4,7 +4,7 @@ #' using an ellipse to determine anomalies on which to select target planes. #' #' Usually, you will not call this function directly, but will pass it to -#' a method that works with tour paths like \code{\link{animate_slice}}, +#' a method that works with tour paths like \code{\link{animate_xy}}, #' \code{\link{save_history}} or \code{\link{render}}. #' #' @param index_f the section pursuit index function to optimise. The function diff --git a/man/guided_anomaly_tour.Rd b/man/guided_anomaly_tour.Rd index a9e81f27..4b182c51 100644 --- a/man/guided_anomaly_tour.Rd +++ b/man/guided_anomaly_tour.Rd @@ -53,7 +53,7 @@ using an ellipse to determine anomalies on which to select target planes. } \details{ Usually, you will not call this function directly, but will pass it to -a method that works with tour paths like \code{\link{animate_slice}}, +a method that works with tour paths like \code{\link{animate_xy}}, \code{\link{save_history}} or \code{\link{render}}. } \examples{ diff --git a/man/norm_bin.Rd b/man/norm_bin.Rd index 1a7376f9..390c2045 100644 --- a/man/norm_bin.Rd +++ b/man/norm_bin.Rd @@ -14,11 +14,11 @@ norm_kol(nr) } \description{ Compares the similarity between the projected distribution and a normal distribution. -} -\details{ +\itemize{ \item norm_bin: compares the count in 100 histogram bins \item norm_kol: compares the cdf based on the Kolmogorov–Smirnov test (KS test) } +} \examples{ # manually compute the norm_kol index # create the index function From 3822a8a45ab9d6c1b153bb361f2a143c23de0ef4 Mon Sep 17 00:00:00 2001 From: dicook Date: Thu, 4 Jul 2024 19:22:53 +1000 Subject: [PATCH 4/8] axis labels option and extreme points option --- DESCRIPTION | 2 +- NEWS.md | 5 +++++ R/display-density2d.r | 6 ++++-- R/display-groupxy.r | 6 ++++-- R/display-pca.r | 6 ++++-- R/display-sage.R | 6 ++++-- R/display-slice.r | 6 ++++-- R/display-trails.r | 5 +++-- R/display-xy.r | 21 +++++++++++++++++---- R/tour-guided-anomaly.r | 2 +- man/display_density2d.Rd | 3 +++ man/display_groupxy.Rd | 3 +++ man/display_pca.Rd | 3 +++ man/display_sage.Rd | 3 +++ man/display_slice.Rd | 3 +++ man/display_trails.Rd | 3 +++ man/display_xy.Rd | 6 ++++++ man/draw_tour_axes.Rd | 4 ++++ 18 files changed, 75 insertions(+), 18 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9f3f8ca9..acab6915 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tourr Title: Tour Methods for Multivariate Data Visualisation -Version: 1.2.0 +Version: 1.2.1 Authors@R: c( person("Hadley", "Wickham", email = "h.wickham@gmail.com", role = c("aut", "ctb"), comment = c(ORCID = "0000-0003-4757-117X")), person("Dianne", "Cook", email = "dicook@monash.edu", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3813-7155")), diff --git a/NEWS.md b/NEWS.md index d9b89378..003b3d2c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# tourr 1.2.1 + +* anomaly tour is initialised with a random basis +* option to label only long axes + # tourr 1.2.0 * major change: rescale is now FALSE by default. diff --git a/R/display-density2d.r b/R/display-density2d.r index b2f9f90d..274668da 100644 --- a/R/display-density2d.r +++ b/R/display-density2d.r @@ -14,6 +14,7 @@ #' @param cex size of the point to be plotted. Defaults to 1. #' @param contour_quartile Vector of quartiles to plot the contours at. Defaults to 5. #' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1" +#' @param axislablong text labels only for the long axes in a projection, default FALSE #' @param ... other arguments passed on to \code{\link{animate}} and #' \code{\link{display_density2d}} #' @importFrom graphics contour @@ -53,7 +54,8 @@ display_density2d <- function(center = TRUE, axes = "center", half_range = NULL, col = "black", pch = 20, cex = 1, contour_quartile = c(.25, .5, .75), edges = NULL, - palette = "Zissou 1", ...) { + palette = "Zissou 1", + axislablong = FALSE, ...) { # If colors are a variable, convert to colors if (is.factor(col) | !areColors(col)) { gps <- col @@ -80,7 +82,7 @@ display_density2d <- function(center = TRUE, axes = "center", half_range = NULL, rect(-1, -1, 1, 1, col = "#FFFFFFE6", border = NA) } render_data <- function(data, proj, geodesic) { - draw_tour_axes(proj, labels, limits = 1, axes) + draw_tour_axes(proj, labels, limits = 1, axes, longlabels=axislablong) # Render projected points x <- data %*% proj diff --git a/R/display-groupxy.r b/R/display-groupxy.r index c72cbaaf..d7c6d54b 100644 --- a/R/display-groupxy.r +++ b/R/display-groupxy.r @@ -22,6 +22,7 @@ #' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1" #' @param shapeset numbers corresponding to shapes in base R points, to use for mapping #' categorical variable to shapes, default=c(15:17, 23:25) +#' @param axislablong text labels only for the long axes in a projection, default FALSE #' @param ... other arguments passed on to \code{\link{animate}} and #' \code{\link{display_groupxy}} #' @export @@ -41,7 +42,8 @@ display_groupxy <- function(centr = TRUE, axes = "center", half_range = NULL, col = "black", pch = 20, cex = 1, edges = NULL, edges.col = "black", edges.width=1, group_by = NULL, plot_xgp = TRUE, - palette = "Zissou 1", shapeset=c(15:17, 23:25), ...) { + palette = "Zissou 1", shapeset=c(15:17, 23:25), + axislablong = FALSE, ...) { labels <- NULL # If colors are a variable, convert to colors @@ -95,7 +97,7 @@ display_groupxy <- function(centr = TRUE, axes = "center", half_range = NULL, x <- x / half_range blank_plot(xlim = c(-1, 1), ylim = c(-1, 1)) - draw_tour_axes(proj, labels, limits = 1, axes) + draw_tour_axes(proj, labels, limits = 1, axes, longlabels=axislablong) # add a legend, only if a variable was used if (is.factor(gps)) { numcol <- unique(col) diff --git a/R/display-pca.r b/R/display-pca.r index e898c2cf..abda235d 100644 --- a/R/display-pca.r +++ b/R/display-pca.r @@ -18,6 +18,7 @@ #' @param edges.col colour of edges to be plotted, Defaults to "black. #' @param rescale Default FALSE. If TRUE, rescale all variables to range [0,1]. #' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1" +#' @param axislablong text labels only for the long axes in a projection, default FALSE #' @param ... other arguments passed on to \code{\link{animate}} and #' \code{\link{display_slice}} #' @export @@ -31,7 +32,8 @@ display_pca <- function(center = TRUE, axes = "center", half_range = NULL, col = "black", pch = 20, cex = 1, pc_coefs = NULL, edges = NULL, edges.col = "black", - palette = "Zissou 1", ...) { + palette = "Zissou 1", + axislablong = FALSE, ...) { labels <- NULL # If colors are a variable, convert to colors @@ -63,7 +65,7 @@ display_pca <- function(center = TRUE, axes = "center", half_range = NULL, render_data <- function(data, proj, geodesic) { # Render axes pc_axes <- pc_coefs %*% proj - draw_tour_axes(pc_axes, labels, limits = 1, axes) + draw_tour_axes(pc_axes, labels, limits = 1, axes, longlabels=axislablong) # Render projected points x <- data %*% proj diff --git a/R/display-sage.R b/R/display-sage.R index 10c456e0..05ad631b 100644 --- a/R/display-sage.R +++ b/R/display-sage.R @@ -13,6 +13,7 @@ #' @param R scale for the radial transformation. #' If not set, defaults to maximum distance from origin to each row of data. #' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1" +#' @param axislablong text labels only for the long axes in a projection, default FALSE #' @param ... other arguments passed on to \code{\link{animate}} and #' \code{\link{display_sage}} #' @export @@ -27,7 +28,8 @@ #' animate_sage(sphere10) display_sage <- function(axes = "center", half_range = NULL, col = "black", pch = 20, gam = 1, R = NULL, - palette = "Zissou 1", ...) { + palette = "Zissou 1", + axislablong = FALSE, ...) { labels <- NULL peff <- NULL @@ -54,7 +56,7 @@ display_sage <- function(axes = "center", half_range = NULL, } render_data <- function(data, proj, geodesic) { - draw_tour_axes(proj, labels, 1, axes) + draw_tour_axes(proj, labels, 1, axes, longlabels=axislablong) # Projecte data and center x <- data %*% proj diff --git a/R/display-slice.r b/R/display-slice.r index 2628ede9..face3924 100644 --- a/R/display-slice.r +++ b/R/display-slice.r @@ -24,6 +24,7 @@ #' @param anchor_nav position of the anchor: center, topright or off #' @param rescale Default FALSE. If TRUE, rescale all variables to range [0,1]. #' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1" +#' @param axislablong text labels only for the long axes in a projection, default FALSE #' @param ... other arguments passed on to \code{\link{animate}} and #' \code{\link{display_slice}} #' @export @@ -51,7 +52,8 @@ display_slice <- function(center = TRUE, axes = "center", half_range = NULL, cex_slice = 2, cex_other = 1, v_rel = NULL, anchor = NULL, anchor_nav = "off", edges = NULL, edges.col = "black", - palette = "Zissou 1", ...) { + palette = "Zissou 1", + axislablong = FALSE, ...) { labels <- NULL h <- NULL @@ -89,7 +91,7 @@ display_slice <- function(center = TRUE, axes = "center", half_range = NULL, } render_data <- function(data, proj, geodesic, with_anchor = anchor) { - draw_tour_axes(proj, labels, limits = 1, axes) + draw_tour_axes(proj, labels, limits = 1, axes, longlabels=axislablong) if (!is.null(with_anchor)) { rng <- apply(data, 2, range) colnames(with_anchor) <- colnames(data) diff --git a/R/display-trails.r b/R/display-trails.r index 1688626c..01b24d0f 100644 --- a/R/display-trails.r +++ b/R/display-trails.r @@ -14,13 +14,14 @@ #' @param past draw line between current projection and projection \code{past} #' steps ago #' @param cex magnification of plotting text relative to default. Defaults to 1. +#' @param axislablong text labels only for the long axes in a projection, default FALSE #' @param ... other arguments passed on to \code{\link{animate}} and #' \code{\link{display_xy}} #' @export #' @examples #' animate_trails(flea[,1:6], col=flea$species) #' -display_trails <- function(center = TRUE, axes = "center", half_range = NULL, col = "black", pch = 20, cex = 1, past = 3, ...) { +display_trails <- function(center = TRUE, axes = "center", half_range = NULL, col = "black", pch = 20, cex = 1, past = 3, axislablong = FALSE, ...) { # Inherit most behaviour from display_xy. This is a little hacky, but # the only way until tourr switch to a proper object system. @@ -35,7 +36,7 @@ display_trails <- function(center = TRUE, axes = "center", half_range = NULL, co # Only difference is the display method render_data <- function(data, proj, geodesic) { - draw_tour_axes(proj, labels, 1, axes) + draw_tour_axes(proj, labels, 1, axes, longlabels=axislablong) x <- data %*% proj if (center) x <- center(x) diff --git a/R/display-xy.r b/R/display-xy.r index a4ef5075..4c83afd7 100644 --- a/R/display-xy.r +++ b/R/display-xy.r @@ -21,9 +21,11 @@ #' scale the ellipse larger or smaller to capture more or fewer anomalies. Default 3. #' @param ellmu This is the centre of the ellipse corresponding to the mean of the #' normal population. Default vector of 0's +#' @param ellmarks mark the extreme points with red crosses, default TRUE #' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1" #' @param shapeset numbers corresponding to shapes in base R points, to use for mapping #' categorical variable to shapes, default=c(15:17, 23:25) +#' @param axislablong text labels only for the long axes in a projection, default FALSE #' @param ... other arguments passed on to \code{\link{animate}} and #' \code{\link{display_xy}} #' @importFrom graphics legend @@ -72,7 +74,9 @@ display_xy <- function(center = TRUE, axes = "center", half_range = NULL, edges = NULL, edges.col = "black", edges.width=1, obs_labels = NULL, ellipse = NULL, ellc = NULL, ellmu = NULL, - palette="Zissou 1", shapeset=c(15:17, 23:25), ...) { + ellmarks = TRUE, + palette="Zissou 1", shapeset=c(15:17, 23:25), + axislablong = FALSE, ...) { # Needed for CRAN checks labels <- NULL gps <- NULL @@ -128,7 +132,7 @@ display_xy <- function(center = TRUE, axes = "center", half_range = NULL, rect(-1, -1, 1, 1, col = "#FFFFFFE6", border = NA) } render_data <- function(data, proj, geodesic) { - draw_tour_axes(proj, labels, limits = 1, axes, ...) + draw_tour_axes(proj, labels, limits = 1, axes, longlabels=axislablong, ...) # Render projected points x <- data %*% proj @@ -227,7 +231,7 @@ display_xy <- function(center = TRUE, axes = "center", half_range = NULL, #mdst <- mahal_dist(data, ellipse) anomalies <- which(mdst > ellc) #cat("1 ", length(anomalies), "\n") - if (length(anomalies) > 0) { + if (length(anomalies) > 0 & ellmarks) { points(x[anomalies,], col = "red", pch = 4, @@ -267,6 +271,7 @@ animate_xy <- function(data, tour_path = grand_tour(), ...) { #' @param axis.col colour of axes, default "grey50" #' @param axis.lwd linewidth of axes, default 1 #' @param axis.text.col colour of axes text, default "grey50" +#' @param longlabels text labels only for the long axes in a projection, default FALSE #' @param ... other arguments passed #' @export #' @examples @@ -284,8 +289,10 @@ animate_xy <- function(data, tour_path = grand_tour(), ...) { #' xlim = c(-3, 3), ylim = c(-3, 3), #' xlab="P1", ylab="P2") #' draw_tour_axes(prj, colnames(flea)[1:6], limits=3, position="bottomleft") +#' draw_tour_axes(prj, colnames(flea)[1:6], axislablong=TRUE) draw_tour_axes <- function(proj, labels, limits=1, position="center", - axis.col= "grey50", axis.lwd=1, axis.text.col= "grey50", ...) { + axis.col="grey50", axis.lwd=1, axis.text.col="grey50", + longlabels, ...) { position <- match.arg(position, c("center", "bottomleft", "off")) if (position == "off") { return() @@ -311,6 +318,12 @@ draw_tour_axes <- function(proj, labels, limits=1, position="center", theta <- seq(0, 2 * pi, length = 50) lines(adj(cos(theta)), adj(sin(theta)), col = axis.col, lwd = axis.lwd) + if (longlabels) { + for (i in 1:length(labels)) { + if ((proj[i, 1]^2 + proj[i, 2]^2) < 0.3) + labels[i] <- "" + } + } text(adj(proj[, 1]), adj(proj[, 2]), label = labels, col = axis.text.col) } diff --git a/R/tour-guided-anomaly.r b/R/tour-guided-anomaly.r index 914806a5..5260c775 100644 --- a/R/tour-guided-anomaly.r +++ b/R/tour-guided-anomaly.r @@ -40,7 +40,7 @@ guided_anomaly_tour <- function(index_f, d = 2, alpha = 0.5, cooling = 0.99, generator <- function(current, data, tries, ...) { if (is.null(current)) { - return(basis_init(ncol(data), d)) + return(basis_random(ncol(data), d)) } if (is.null(h)) { diff --git a/man/display_density2d.Rd b/man/display_density2d.Rd index 1f6a5ac4..1f1ca49e 100644 --- a/man/display_density2d.Rd +++ b/man/display_density2d.Rd @@ -15,6 +15,7 @@ display_density2d( contour_quartile = c(0.25, 0.5, 0.75), edges = NULL, palette = "Zissou 1", + axislablong = FALSE, ... ) @@ -42,6 +43,8 @@ If not set, defaults to maximum distance from origin to each row of data.} \item{palette}{name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"} +\item{axislablong}{text labels only for the long axes in a projection, default FALSE} + \item{...}{other arguments passed on to \code{\link{animate}} and \code{\link{display_density2d}}} diff --git a/man/display_groupxy.Rd b/man/display_groupxy.Rd index 0db34e08..c6c15ddb 100644 --- a/man/display_groupxy.Rd +++ b/man/display_groupxy.Rd @@ -19,6 +19,7 @@ display_groupxy( plot_xgp = TRUE, palette = "Zissou 1", shapeset = c(15:17, 23:25), + axislablong = FALSE, ... ) @@ -55,6 +56,8 @@ If not set, defaults to maximum distance from origin to each row of data.} \item{shapeset}{numbers corresponding to shapes in base R points, to use for mapping categorical variable to shapes, default=c(15:17, 23:25)} +\item{axislablong}{text labels only for the long axes in a projection, default FALSE} + \item{...}{other arguments passed on to \code{\link{animate}} and \code{\link{display_groupxy}}} diff --git a/man/display_pca.Rd b/man/display_pca.Rd index d6a40958..bb3f75e7 100644 --- a/man/display_pca.Rd +++ b/man/display_pca.Rd @@ -16,6 +16,7 @@ display_pca( edges = NULL, edges.col = "black", palette = "Zissou 1", + axislablong = FALSE, ... ) @@ -46,6 +47,8 @@ principal components. This is required.} \item{palette}{name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"} +\item{axislablong}{text labels only for the long axes in a projection, default FALSE} + \item{...}{other arguments passed on to \code{\link{animate}} and \code{\link{display_slice}}} diff --git a/man/display_sage.Rd b/man/display_sage.Rd index 66202f94..7a37b7d0 100644 --- a/man/display_sage.Rd +++ b/man/display_sage.Rd @@ -13,6 +13,7 @@ display_sage( gam = 1, R = NULL, palette = "Zissou 1", + axislablong = FALSE, ... ) @@ -35,6 +36,8 @@ If not set, defaults to maximum distance from origin to each row of data.} \item{palette}{name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"} +\item{axislablong}{text labels only for the long axes in a projection, default FALSE} + \item{...}{other arguments passed on to \code{\link{animate}} and \code{\link{display_sage}}} diff --git a/man/display_slice.Rd b/man/display_slice.Rd index b9574c94..9b297052 100644 --- a/man/display_slice.Rd +++ b/man/display_slice.Rd @@ -20,6 +20,7 @@ display_slice( edges = NULL, edges.col = "black", palette = "Zissou 1", + axislablong = FALSE, ... ) @@ -61,6 +62,8 @@ If NULL (default) the slice will be anchored at the data center.} \item{palette}{name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"} +\item{axislablong}{text labels only for the long axes in a projection, default FALSE} + \item{...}{other arguments passed on to \code{\link{animate}} and \code{\link{display_slice}}} diff --git a/man/display_trails.Rd b/man/display_trails.Rd index 2670b56d..8130fc79 100644 --- a/man/display_trails.Rd +++ b/man/display_trails.Rd @@ -13,6 +13,7 @@ display_trails( pch = 20, cex = 1, past = 3, + axislablong = FALSE, ... ) @@ -37,6 +38,8 @@ If not set, defaults to maximum distance from origin to each row of data.} \item{past}{draw line between current projection and projection \code{past} steps ago} +\item{axislablong}{text labels only for the long axes in a projection, default FALSE} + \item{...}{other arguments passed on to \code{\link{animate}} and \code{\link{display_xy}}} diff --git a/man/display_xy.Rd b/man/display_xy.Rd index 9e4f331d..fb1eecc5 100644 --- a/man/display_xy.Rd +++ b/man/display_xy.Rd @@ -19,8 +19,10 @@ display_xy( ellipse = NULL, ellc = NULL, ellmu = NULL, + ellmarks = TRUE, palette = "Zissou 1", shapeset = c(15:17, 23:25), + axislablong = FALSE, ... ) @@ -59,11 +61,15 @@ scale the ellipse larger or smaller to capture more or fewer anomalies. Default \item{ellmu}{This is the centre of the ellipse corresponding to the mean of the normal population. Default vector of 0's} +\item{ellmarks}{mark the extreme points with red crosses, default TRUE} + \item{palette}{name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"} \item{shapeset}{numbers corresponding to shapes in base R points, to use for mapping categorical variable to shapes, default=c(15:17, 23:25)} +\item{axislablong}{text labels only for the long axes in a projection, default FALSE} + \item{...}{other arguments passed on to \code{\link{animate}} and \code{\link{display_xy}}} diff --git a/man/draw_tour_axes.Rd b/man/draw_tour_axes.Rd index a42c5b1f..c73aa71b 100644 --- a/man/draw_tour_axes.Rd +++ b/man/draw_tour_axes.Rd @@ -12,6 +12,7 @@ draw_tour_axes( axis.col = "grey50", axis.lwd = 1, axis.text.col = "grey50", + longlabels, ... ) } @@ -33,6 +34,8 @@ bottomleft or off} \item{axis.text.col}{colour of axes text, default "grey50"} +\item{longlabels}{text labels only for the long axes in a projection, default FALSE} + \item{...}{other arguments passed} } \description{ @@ -53,4 +56,5 @@ plot(flea_prj$V1, flea_prj$V2, xlim = c(-3, 3), ylim = c(-3, 3), xlab="P1", ylab="P2") draw_tour_axes(prj, colnames(flea)[1:6], limits=3, position="bottomleft") +draw_tour_axes(prj, colnames(flea)[1:6], axislablong=TRUE) } From 061708a6ea3174807b66786baeea347eb47a1ca8 Mon Sep 17 00:00:00 2001 From: dicook Date: Fri, 5 Jul 2024 00:05:06 +1000 Subject: [PATCH 5/8] smaller cutoff for long labels --- R/display-xy.r | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/display-xy.r b/R/display-xy.r index 4c83afd7..54beaa05 100644 --- a/R/display-xy.r +++ b/R/display-xy.r @@ -320,7 +320,7 @@ draw_tour_axes <- function(proj, labels, limits=1, position="center", col = axis.col, lwd = axis.lwd) if (longlabels) { for (i in 1:length(labels)) { - if ((proj[i, 1]^2 + proj[i, 2]^2) < 0.3) + if ((proj[i, 1]^2 + proj[i, 2]^2) < 0.15) labels[i] <- "" } } From fcc470e2712072d1ac88a42c37ed81aca8f46be7 Mon Sep 17 00:00:00 2001 From: dicook Date: Fri, 5 Jul 2024 23:22:28 +1000 Subject: [PATCH 6/8] save_history and lda_pp bug fix --- NEWS.md | 1 + R/interesting-indices.r | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 003b3d2c..4cbeb51c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ * anomaly tour is initialised with a random basis * option to label only long axes +* bug fix for save_history with lda_pp # tourr 1.2.0 diff --git a/R/interesting-indices.r b/R/interesting-indices.r index 3cb1997d..1eecf72d 100644 --- a/R/interesting-indices.r +++ b/R/interesting-indices.r @@ -150,7 +150,7 @@ lda_pp <- function(cl) { 1 - summary(fit, test = "Wilks")$stats[[3]] } else { - summary(stats::aov(mat ~ cl))[[1]][4] + summary(stats::aov(mat ~ cl))[[1]][1,4] } } } From 125e2520f954f96ea8c136afc12e722b3f2811b8 Mon Sep 17 00:00:00 2001 From: dicook Date: Sun, 1 Sep 2024 15:15:23 +1000 Subject: [PATCH 7/8] skewness index added --- DESCRIPTION | 2 +- NAMESPACE | 1 + NEWS.md | 4 ++++ R/interesting-indices.r | 19 +++++++++++++++++++ man/tourr-package.Rd | 1 + 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index e62e0b17..91528567 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tourr Title: Tour Methods for Multivariate Data Visualisation -Version: 1.2.1 +Version: 1.2.2 Authors@R: c( person("Hadley", "Wickham", email = "h.wickham@gmail.com", role = c("aut", "ctb"), comment = c(ORCID = "0000-0003-4757-117X")), person("Dianne", "Cook", email = "dicook@monash.edu", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3813-7155")), diff --git a/NAMESPACE b/NAMESPACE index dfd15912..e0c6e112 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -108,6 +108,7 @@ export(search_better_random) export(search_geodesic) export(search_polish) export(search_posse) +export(skewness) export(slice_index) export(sphere_data) export(splines2d) diff --git a/NEWS.md b/NEWS.md index 4cbeb51c..46e3124e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# tourr 1.2.2 + +* New skewness index, as defined in original Cook, Buja, Cabrera paper + # tourr 1.2.1 * anomaly tour is initialised with a random basis diff --git a/R/interesting-indices.r b/R/interesting-indices.r index 1eecf72d..9d399e69 100644 --- a/R/interesting-indices.r +++ b/R/interesting-indices.r @@ -128,6 +128,25 @@ cmass <- function() { } } +#' Skewness index. +#' +#' Calculates the skewness index. See Cook, Buja and Cabrera (1993) +#' Projection pursuit indexes based on orthonormal function expansions +#' for equations. +#' +#' @keywords hplot +#' @export +skewness <- function() { + function(mat) { + n <- nrow(mat) + d <- ncol(mat) + + idx <- mean(rowSums(mat * exp(-0.5 * mat^2))) + + idx + } +} + #' LDA projection pursuit index. #' #' Calculate the LDA projection pursuit index. See Cook and Swayne (2007) diff --git a/man/tourr-package.Rd b/man/tourr-package.Rd index 608bdc6c..33774211 100644 --- a/man/tourr-package.Rd +++ b/man/tourr-package.Rd @@ -14,6 +14,7 @@ Implements geodesic interpolation and basis generation functions that allow you Useful links: \itemize{ \item \url{https://github.com/ggobi/tourr} + \item \url{https://ggobi.github.io/tourr/} \item Report bugs at \url{https://github.com/ggobi/tourr/issues} } From 6fa03da8e7dc1b8b6fd5bbdc89713d68bbd0ef68 Mon Sep 17 00:00:00 2001 From: dicook Date: Tue, 3 Sep 2024 08:23:41 +1000 Subject: [PATCH 8/8] update to version and news --- DESCRIPTION | 2 +- NEWS.md | 8 +++++++- R/animate.r | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d9759ce8..c718cee1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tourr Title: Tour Methods for Multivariate Data Visualisation -Version: 1.2.2 +Version: 1.2.3 Authors@R: c( person("Hadley", "Wickham", email = "h.wickham@gmail.com", role = c("aut", "ctb"), comment = c(ORCID = "0000-0003-4757-117X")), person("Dianne", "Cook", email = "dicook@monash.edu", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3813-7155")), diff --git a/NEWS.md b/NEWS.md index 46e3124e..57299126 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,12 @@ +# tourr 1.2.3 + +* New optimisation routine, using the jellyfish optimiser. +* New PP indexes from cassowaryr package, stringy, MIC and TIC. +* Attempted fix for positron, but still not working. + # tourr 1.2.2 -* New skewness index, as defined in original Cook, Buja, Cabrera paper +* New skewness index, as defined in original Cook, Buja, Cabrera paper. # tourr 1.2.1 diff --git a/R/animate.r b/R/animate.r index d767ed88..b78a6f5f 100644 --- a/R/animate.r +++ b/R/animate.r @@ -62,7 +62,7 @@ animate <- function(data, tour_path = grand_tour(), display = display_xy(), to_stop() } plat <- find_platform() - if (rstudio_gd() && fps > 19) { + if ((rstudio_gd() && fps > 19) || (positron_gd() && fps > 19)) { warning("Rstudio graphics device supports maximum fps of 19", call. = FALSE) fps <- 19 } @@ -102,7 +102,7 @@ animate <- function(data, tour_path = grand_tour(), display = display_xy(), if (!is.null(start$target)){ dev.hold() on.exit(dev.flush()) - if (plat$os == "win" || plat$iface == "rstudio") { + if (plat$os == "win" || plat$iface == "rstudio" || plat$iface == "cli") { display$render_frame() } else { display$render_transition() @@ -131,5 +131,6 @@ animate <- function(data, tour_path = grand_tour(), display = display_xy(), } rstudio_gd <- function() identical(names(dev.cur()), "RStudioGD") +positron_gd <- function() identical(names(dev.cur()), "Positron Graphics Device") # globalVariables("record")