qtour: Create a tour associated with a mutaframe

Description Usage Arguments Details Value Author(s) Examples

View source: R/qtour.R

Description

The tourr package is used to create the tour projections. This function creates an R object to manipulate the tour, and all the changes in the tour can be reflected immediately in plots created in cranvas.

Usage

1
2
qtour(vars = ~., data, tour_path, aps = 1, fps = 30, rescale = TRUE, sphere = FALSE, 
    ...)

Arguments

vars

variable names to be used in the tour (parsed by var_names)

data

a mutaframe created by qdata

tour_path

tour path generator, defaults to 2d grand tour

aps

target angular velocity (in radians per second)

fps

target frames per second (defaults to 30)

rescale

if true, rescale all variables to range [0,1]?

sphere

if true, sphere all variables

...

ignored

Details

Because the data provided to the tour is a mutaframe, it can listen to changes through listeners on it. Usually these listeners can update the plots which are created from this mutaframe (further, those linked to this mutaframe) on the fly.

Four basic methods can be applied to the object returned by this function (say, tour):

tour$start()

starts the tour (tour projections change successively and are attached to the mutaframe; column names are tour_1, tour_2, ...)

tour$stop()

pauses the tour

tour$slower()

makes the tour slower

tour$faster()

makes it faster.

We can also modify the parameters passed to qtour() on the fly through this object. For example, we can change the type of tour to the guided tour using a syntax like tour$tour_path <- guided_tour(...). All other parameters can be changed similarly, including vars, aps, fps, rescale and sphere.

Value

An object generated by reference classes with signals.

Author(s)

Yihui Xie and Di Cook

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
library(cranvas)
library(tourr)
data(flea, package = "tourr")

qflea <- qdata(flea, color = species)
flea_tour <- qtour(1:6, data = qflea, tour_path = grand_tour(3))
flea_tour$start()

# Sys.sleep(.5) # need a pause to generate projections
qscatter(proj1, proj2, data = qflea, xlim = c(-0.8, 0.8), ylim = c(-0.8, 
    0.8), xlab = "Projection 1", ylab = "Projection 2")
qscatter(proj1, proj2, edges = matrix(c(1:5, 2:6), ncol = 2, byrow = T), 
    data = qflea, xlim = c(-0.8, 0.8), ylim = c(-0.8, 0.8), xlab = "Projection 1", 
    ylab = "Projection 2")
qparallel(~proj1 + proj2 + proj3, data = qflea)
# qhist(proj1, data = qflea, binwidth = 0.05, xlim = c(-1, 1), ylim =
# c(0, 15))
qhist(proj1, data = qflea, breaks = seq(-1, 1, 0.1), ybreaks = seq(0, 20, 
    5))

flea_tour$pause()

## adjust speed
flea_tour$start()
flea_tour$setSpeed(2)  # speed up (twice as fast)
flea_tour$setSpeed(0.5)  # slow down
flea_tour$faster()
flea_tour$slower()

## change the type of tour
flea_tour$tour_path <- guided_tour(holes, d = 3)
flea_tour$tour_path <- grand_tour(d = 3)
flea_tour$tour_path <- guided_tour(lda_pp(flea$species), d = 3)
flea_tour$tour_path <- grand_tour(d = 3)

## do sphering
flea_tour$sphere <- TRUE

cranvas_off()

ggobi/cranvas documentation built on May 17, 2019, 3:10 a.m.