# Here is a very short example based on these two time series
ts_1 <- c(0, 0, 1, 1, 0, 0, 2, 2, 1, 1)
ts_2 <- c(1, 1, 2, 2, 0, 0, 1, 2, 2, 1)
# Create the cross recurrence matrix
short_rec <- crqa(ts_1, ts_2,
delay = 1, embed = 1, radius = 0.001,
rescale = 1, method = "crqa")
# Extract the cross recurrence matrix
small_rp <- short_rec$RP
# Make a cross recurrence plot with blue tiles
plot_rp(small_rp, pcolour = "blue", geom = "tile")
# Make a cross recurrenbce plot with blue points
plot_rp(small_rp, pcolour = "blue", geom = "point")
## Uncomment below if you want to have more example. Not runnable because
## of CRAN, globally unavailable function plus timing constraint to check vignette.
# Neither of the two plots above may be suitable
# Using geom = "void" we can add a custumized geom, here blue tiles
# that are smaller than the default width and height
# plot_rp(small_rp, geom = "void") +
# geom_tile(fill = "blue", height = 0.75, width = 0.75)
# Another custom geom uses tiles with a border colour
# plot_rp(small_rp, geom = "void") +
# geom_tile(fill = "blue", colour = "pink", linewidth = 1)
# Use the eyemovement dataset to create a cross-recurrence plot
# large_crqa <- crqa(eyemovement$narrator, eyemovement$listener,
# delay = 1, embed = 1, radius = 0.001,
# method = "crqa", metric = "euclidean", datatype = "continuous")
# Extract the recurrence matrix from the result
# large_rp <- large_crqa$RP
# Create a recurrence plot using defaults
# plot_rp(large_rp)
# The same recurrence plot with flipped y axis and using geom_point()
# plot_rp(large_rp, flip_y = TRUE, geom = "point", title = "Flipped y axis")
# Add axes labels, a title and extra plot elements
# Note that we can add to the output, here added the line of synchonization
# using ggplot2's geom_abline() function.
# plot_rp(large_rp,
# xlabel = "Narrator",
# ylabel = "Listener",
# title = "Coloured tiles with line of synchronization",
# pcolour = "blue") +
# geom_abline(intercept = 0, slope = 1)
Run the code above in your browser using DataLab