Skip to content

Commit

Permalink
fixes for CRAN submission
Browse files Browse the repository at this point in the history
  • Loading branch information
dicook committed Jun 19, 2023
1 parent 9582836 commit d29c63e
Show file tree
Hide file tree
Showing 365 changed files with 692 additions and 1,737 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: tourr
Title: Tour Methods for Multivariate Data Visualisation
Version: 0.6.18
Version: 1.0.0
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")),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# tourr 1.0.0

* Small changes in prep for CRAN
* Time for it to be a full version number

# tourr 0.6.18

* Changed line colours to take a factor, and be handled the same as points.
Expand Down
3 changes: 2 additions & 1 deletion R/display-andrews.r
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ andrews <- function(x) {
#' Andrew's curves, see \code{\link{andrews}}
#'
#' @param col color to be plotted. Defaults to "black"
#' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"
#' @param ... other arguments passed on to \code{\link{animate}}
#' @seealso \code{\link{animate}} for options that apply to all animations
#' @keywords hplot
Expand All @@ -47,7 +48,7 @@ andrews <- function(x) {
#'
#' # It's easy to experiment with different tour paths:
#' animate_andrews(flea[, 1:6], guided_tour(cmass()))
display_andrews <- function(col = "black", ...) {
display_andrews <- function(col = "black", palette = "Zissou 1", ...) {
grid <- NULL
init <- function(data) {
grid <<- seq(-pi, pi, length = 50)
Expand Down
2 changes: 1 addition & 1 deletion R/display-density.r
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' If not set, defaults to maximum distance from origin to each row of data.
#' @param col color to use for points, can be a vector or hexcolors or a factor. Defaults to "black".
#' @param rug draw rug plot showing position of actual data points?
#' @param palette name of color palette for point colour, used by \code{\link{grDevices::hcl.colors}}, default "Zissou 1"
#' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"
#' @param density_max allow control of the y range for density plot
#' @param bw binwidth for histogram and density, between 0-1, default 0.2
#' @param scale_density Height of density is scaled at each projection, default FALSE
Expand Down
2 changes: 1 addition & 1 deletion R/display-density2d.r
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' @param pch shape of the point to be plotted. Defaults to 20.
#' @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{grDevices::hcl.colors}}, default "Zissou 1"
#' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"
#' @param ... other arguments passed on to \code{\link{animate}} and
#' \code{\link{display_density2d}}
#' @importFrom graphics contour
Expand Down
7 changes: 4 additions & 3 deletions R/display-faces.r
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
#' @examples
#' # The drawing code is fairly slow, so this animation works best with a
#' # limited number of cases
#' animate_faces(flea[1:2, 1:6])
#' animate_faces(flea[1:4, 1:6])
#' flea_s <- rescale(flea[,1:6])
#' animate_faces(flea_s[1:2, 1:6])
#' animate_faces(flea_s[1:4, 1:6])
#'
#' animate_faces(flea[1:2, 1:6], grand_tour(5))
#' animate_faces(flea_s[1:2, 1:6], grand_tour(5))
display_faces <- function(...) {
if (!requireNamespace("TeachingDemos", quietly = TRUE)) {
stop("Please install the TeachingDemos package", call. = FALSE)
Expand Down
53 changes: 40 additions & 13 deletions R/display-groupxy.r
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@
#' @param cex size of the point to be plotted. Defaults to 1.
#' @param group_by variable to group by. Must have less than 25 unique values.
#' @param plot_xgp if TRUE, plots points from other groups in light grey
#' @param palette name of color palette for point colour, used by \code{\link{grDevices::hcl.colors}}, default "Zissou 1"
#' @param edges.col colour of edges to be plotted, Defaults to "black"
#' @param edges.width line width for edges, default 1
#' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"
#' @param ... other arguments passed on to \code{\link{animate}} and
#' \code{\link{display_groupxy}}
#' @export
#' @examples
#' f <- flea[, 1:6]
#' col <- rainbow(length(unique(flea$species)))[as.numeric(as.factor(flea$species))]
#' pch <- as.numeric(flea$species) + 14
#'
#' animate_groupxy(f, col = col, pch = pch, group_by = flea$species)
#' animate_groupxy(f, col = col, pch = pch, group_by = flea$species, plot_xgp = FALSE)
#' animate_groupxy(flea[, 1:6], col = flea$species,
#' pch = flea$species, group_by = flea$species)
#' animate_groupxy(flea[, 1:6], col = flea$species,
#' pch = flea$species, group_by = flea$species,
#' plot_xgp = FALSE)
display_groupxy <- function(centr = TRUE, axes = "center", half_range = NULL,
col = "black", pch = 20, cex = 1, edges = NULL,
col = "black", pch = 20, cex = 1,
edges = NULL, edges.col = "black", edges.width=1,
group_by = NULL, plot_xgp = TRUE,
palette = "Zissou 1", ...) {
labels <- NULL
Expand All @@ -43,6 +45,12 @@ display_groupxy <- function(centr = TRUE, axes = "center", half_range = NULL,
edges.gps <- edges.col
edges.col <- mapColors(edges.col, palette)
}
# If shapes are a variable, convert shapes
if (is.factor(pch)) {
shapes <- mapShapes(pch)
} else {
shapes <- pch
}

init <- function(data) {
half_range <<- compute_half_range(half_range, data, centr)
Expand Down Expand Up @@ -77,28 +85,45 @@ display_groupxy <- function(centr = TRUE, axes = "center", half_range = NULL,

blank_plot(xlim = c(-1, 1), ylim = c(-1, 1))
draw_tour_axes(proj, labels, limits = 1, axes)
# add a legend, only if a variable was used
if (is.factor(gps)) {
numcol <- unique(col)
if (length(numcol) > 1) {
legend("topright", legend=unique(gps),
col=numcol, pch=15)
}
}
if (is.factor(pch)) {
numpch <- unique(shapes)
if (length(numpch) > 1) {
legend("bottomright", legend=unique(pch),
col="black", pch=unique(shapes))
}
}

if (ngps < 2) {
points(x, col = col, pch = pch, cex = cex, new = FALSE)
points(x, col = col, pch = shapes, cex = cex, new = FALSE)
if (!is.null(edges)) {
segments(
x[edges[, 1], 1], x[edges[, 1], 2],
x[edges[, 2], 1], x[edges[, 2], 2]
x[edges[, 2], 1], x[edges[, 2], 2],
col = edges.col,
lwd = edges.width
)
}
}
else {
for (i in 1:ngps) {
x.sub <- x[group_by == gps[i], ]
col.sub <- if (length(col) == nrow(x)) col[group_by == gps[i]] else col
pch.sub <- if (length(pch) == nrow(x)) pch[group_by == gps[i]] else pch
pch.sub <- if (length(shapes) == nrow(x)) shapes[group_by == gps[i]] else shapes
cex.sub <- if (length(cex) == nrow(x)) cex[group_by == gps[i]] else cex

blank_plot(xlim = c(-1, 1), ylim = c(-1, 1))
if (plot_xgp) {
points(x[group_by != gps[i], ],
col = "#DEDEDEDE", new = FALSE,
pch = if (length(pch) > 1) pch[group_by != gps[i]] else pch,
shapes = if (length(shapes) > 1) shapes[group_by != gps[i]] else shapes,
cex = if (length(cex) > 1) cex[group_by != gps[i]] else cex
)
}
Expand All @@ -107,7 +132,9 @@ display_groupxy <- function(centr = TRUE, axes = "center", half_range = NULL,
if (!is.null(edges)) {
segments(
x[edges[group_by == gps[i], 1], 1], x[edges[group_by == gps[i], 1], 2],
x[edges[group_by == gps[i], 2], 1], x[edges[group_by == gps[i], 2], 2]
x[edges[group_by == gps[i], 2], 1], x[edges[group_by == gps[i], 2], 2],
col = edges.col[group_by == gps[i]],
lwd = edges.width
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions R/display-pca.r
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
#' @param edges A two column integer matrix giving indices of ends of lines.
#' @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{grDevices::hcl.colors}}, default "Zissou 1"
#' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"
#' @param ... other arguments passed on to \code{\link{animate}} and
#' \code{\link{display_slice}}
#' @export
#' @examples
#' flea_std <- scale(flea[, 1:6])
#' flea_std <- apply(flea[,1:6], 2, function(x) (x-mean(x))/sd(x))
#' flea_pca <- prcomp(flea_std, center = FALSE, )
#' flea_coefs <- flea_pca$rotation[, 1:3]
#' flea_scores <- flea_pca$x[, 1:3]
Expand Down
2 changes: 1 addition & 1 deletion R/display-sage.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @param gam scaling of the effective dimensionality for rescaling. Defaults to 1.
#' @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{grDevices::hcl.colors}}, default "Zissou 1"
#' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"
#' @param ... other arguments passed on to \code{\link{animate}} and
#' \code{\link{display_sage}}
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/display-slice.r
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#' If NULL (default) the slice will be anchored at the data center.
#' @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{grDevices::hcl.colors}}, default "Zissou 1"
#' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"
#' @param ... other arguments passed on to \code{\link{animate}} and
#' \code{\link{display_slice}}
#' @export
Expand Down
3 changes: 3 additions & 0 deletions R/display-trails.r
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#' @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, ...) {

# Inherit most behaviour from display_xy. This is a little hacky, but
Expand Down
7 changes: 4 additions & 3 deletions R/display-xy.r
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' @param edges.col colour of edges to be plotted, Defaults to "black"
#' @param obs_labels vector of text labels to display
#' @param edges.width line width for edges, default 1
#' @param palette name of color palette for point colour, used by \code{\link{grDevices::hcl.colors}}, default "Zissou 1"
#' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"
#' @param ... other arguments passed on to \code{\link{animate}} and
#' \code{\link{display_xy}}
#' @importFrom graphics legend
Expand All @@ -25,7 +25,8 @@
#' animate(flea[, 1:6], tour_path = grand_tour(), display = display_xy())
#' animate(flea[, 1:6],
#' tour_path = grand_tour(),
#' display = display_xy(axes = "bottomleft")
#' display = display_xy(),
#' scale = TRUE
#' )
#' animate(flea[, 1:6],
#' tour_path = grand_tour(),
Expand All @@ -44,7 +45,7 @@
#'
#' animate_xy(flea[, -7], col = flea$species)
#' animate_xy(flea[, -7], col = flea$species,
#' pch = as.numeric(flea$species))
#' pch = flea$species)
#'
#' animate_xy(flea[, -7], col = flea$species,
#' obs_labels=as.character(1:nrow(flea)), axes="off")
Expand Down
2 changes: 1 addition & 1 deletion R/manual_slice.r
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' @param half_range half range to use when calculating limits of projected.
#' If not set, defaults to maximum distance from origin to each row of data.
#' @param anchor_nav position of the anchor: center, topright or off
#' @param palette name of color palette for point colour, used by \code{\link{grDevices::hcl.colors}}, default "Zissou 1"
#' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"
#' @param ... other options passed to output device
#' @export
#' @examples
Expand Down
21 changes: 10 additions & 11 deletions R/path-dist.r
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#' @examples
#' # This code is to be used as an example but you should increase
#' # the max from 2 to 50, say, to check tour coverage.
#' grand <- interpolate(save_history(flea[, 1:6], max = 2), 0.2)
#' flea_std <- apply(flea[,1:6], 2, function(x) (x-mean(x))/sd(x))
#' grand <- interpolate(save_history(flea_std, max = 2), 0.2)
#' # The grand tour -----------------------------
#' # Look at the tour path in a tour, how well does it cover a sphere
#' # Using MDS to summarise the high-d space of projections
Expand All @@ -20,7 +21,7 @@
#'
#' # Compare five guided tours -----------------------------
#' holes1d <- guided_tour(holes(), 1)
#' tour_reps <- replicate(5, save_history(flea[, 1:6], holes1d, max = 2),
#' tour_reps <- replicate(5, save_history(flea_std, holes1d, max = 2),
#' simplify = FALSE
#' )
#' tour_reps2 <- lapply(tour_reps, interpolate, 0.2)
Expand All @@ -33,15 +34,13 @@
#' ord <- as.data.frame(cmdscale(d, 2))
#'
#' info <- cbind(ord, index_values)
#' if (require("ggplot2")) {
#' ggplot(data = info, aes(x = step, y = value, group = try)) +
#' geom_line()
#' ##ggplot(data = info, aes(x = V1, y = V2, group = try)) +
#' ## geom_path() +
#' ## geom_point(aes(size = value)) +
#' ## coord_equal()
#' ##last_plot() + facet_wrap(~try)
#' }
#' ggplot(data = info, aes(x = step, y = value, group = try)) +
#' geom_line()
#' ##ggplot(data = info, aes(x = V1, y = V2, group = try)) +
#' ## geom_path() +
#' ## geom_point(aes(size = value)) +
#' ## coord_equal()
#' ##last_plot() + facet_wrap(~try)
path_dist <- function(history) {
history <- as.array(history)
n <- dim(history)[3]
Expand Down
11 changes: 6 additions & 5 deletions R/tour-guided.r
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@
#' \code{\link{search_better_random}} for different search strategies
#' @export
#' @examples
#' animate_xy(flea[, 1:6], guided_tour(holes()), sphere = TRUE)
#' flea_std <- apply(flea[,1:6], 2, function(x) (x-mean(x))/sd(x))
#' animate_xy(flea_std, guided_tour(holes()), sphere = TRUE)
#' \donttest{
#' animate_xy(flea[, 1:6], guided_tour(holes(), search_f = search_better_random), sphere = TRUE)
#' animate_dist(flea[, 1:6], guided_tour(holes(), 1), sphere = TRUE)
#' animate_xy(flea[, 1:6], guided_tour(lda_pp(flea$species)), sphere = TRUE, col = flea$species)
#' animate_xy(flea_std, guided_tour(holes(), search_f = search_better_random), sphere = TRUE)
#' animate_dist(flea_std, guided_tour(holes(), 1), sphere = TRUE)
#' animate_xy(flea_std, guided_tour(lda_pp(flea$species)), sphere = TRUE, col = flea$species)
#'
#' # save_history is particularly useful in conjunction with the
#' # guided tour as it allows us to look at the tour path in many different
#' # ways
#' f <- flea[, 1:3]
#' f <- flea_std[, 1:3]
#' tries <- replicate(5, save_history(f, guided_tour(holes())), simplify = FALSE)
#' }
guided_tour <- function(index_f, d = 2, alpha = 0.5, cooling = 0.99, max.tries = 25,
Expand Down
2 changes: 1 addition & 1 deletion R/util.r
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ areColors <- function(x) {
#' Map vector of factors to color
#'
#' @param x vector
#' @param palette name of color palette for point colour, used by \code{\link{grDevices::hcl.colors}}, default "Zissou 1"
#' @param palette name of color palette for point colour, used by \code{\link{hcl.colors}}, default "Zissou 1"
#' @export
mapColors <- function(x, palette) {
n <- length(unique(x))
Expand Down
25 changes: 12 additions & 13 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
## Overview

This is a small updated, with several new methods added, and multiple fixes.

Although the New Maintainer is flagged, the maintainer is the same. The only change is that full name is now used, so that it matches the ORCID records.
This is a fairly major update, with new display options and new parameters on many display options. There are no major structural changes to the code.

\dontrun is used for example code where the method would break, and thus the code should not be run. It is important for users to be able to see this example.

Expand All @@ -13,22 +11,19 @@ Although the New Maintainer is flagged, the maintainer is the same. The only cha
* Fedora Linux, R-devel, clang, gfortran
* Ubuntu Linux 20.04.1 LTS, R-release, GCC

## R CMD check results
## ── R CMD check results ──────────────────────── tourr 1.0.0 ────
Duration: 1m 16.8s

0 errors ✔ | 0 warnings ✔ | 0 notes ✔

## Downstream dependencies

All downstream dependencies have been checked.

> revdep_check()
── INIT ────────────────────────────── Computing revdeps ──
── INSTALL ────────────────────────────────── 2 versions ──
Installing CRAN version of tourr
Installing DEV version of tourr
── CHECK ─────────────────────────────────── 10 packages ──
✔ cheem 0.2.0 ── E: 0 | W: 0 | N: 1
✔ composits 0.1.1 ── E: 0 | W: 0 | N: 0
> revdepcheck::revdep_check()
── CHECK ──────────────────────────────────────── 11 packages ──
✔ cheem 0.3.0 ── E: 0 | W: 0 | N: 0
✔ composits 0.1.1 ── E: 1 | W: 0 | N: 0
✔ detourr 0.1.0 ── E: 0 | W: 0 | N: 1
✔ diveR 0.1.2 ── E: 1 | W: 0 | N: 0
✔ ferrn 0.0.2 ── E: 0 | W: 0 | N: 0
Expand All @@ -37,5 +32,9 @@ Installing DEV version of tourr
✔ loon.tourr 0.1.3 ── E: 1 | W: 0 | N: 0
I REPPlab 0.9.4 ── E: 1 | W: 0 | N: 0
✔ spinifex 0.3.6 ── E: 0 | W: 0 | N: 0
OK: 10
✔ woylier 0.0.5 ── E: 0 | W: 0 | N: 0
OK: 11
BROKEN: 0
Total time: 17 min

REPPlab cannot be fully checked. It doesn't Depend but only Suggests the tourr package.
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d29c63e

Please sign in to comment.