@@ -776,6 +776,7 @@ plotMoves <- function(input, tags, title, xlab, ylab, col, array.alias, show.rel
776776# ' @param tag The transmitter to be plotted.
777777# ' @param type DEPRECATED. Please use the argument y.axis instead.
778778# ' @param y.axis The type of y axis desired. One of "stations" (default) or "arrays".
779+ # ' @param y.order A vector with the desired order for the y-axis values.
779780# ' @param title An optional title for the plot. If left empty, a default title will be added.
780781# ' @param xlab,ylab Optional axis names for the plot. If left empty, default axis names will be added.
781782# ' @param col An optional colour scheme for the detections. If left empty, default colours will be added.
@@ -810,8 +811,8 @@ plotMoves <- function(input, tags, title, xlab, ylab, col, array.alias, show.rel
810811# ' @export
811812# '
812813plotDetections <- function (input , tag , type ,
813- y.axis = c(" auto" , " stations" , " arrays" ), title ,
814- xlab , ylab , col , array.alias , section.alias ,
814+ y.axis = c(" auto" , " stations" , " arrays" ), y.order ,
815+ title , xlab , ylab , col , array.alias , section.alias ,
815816 frame.warning = TRUE , x.label.format ,
816817 only.valid = FALSE , like.migration = TRUE ) {
817818 # NOTE: The NULL variables below are actually column names used by ggplot.
@@ -975,12 +976,30 @@ plotDetections <- function(input, tag, type,
975976 names(link ) <- 1 : length(link )
976977 link <- sort(link )
977978 link <- as.numeric(names(link ))
978- y.order <- spatial $ stations $ Standard.name [link ]
979+ tmp. y.order <- spatial $ stations $ Standard.name [link ]
979980 } else {
980981 if (any(detections $ Array == " Unknown" )) {
981- y.order <- c(array.order $ Array , " Unknown" )
982+ tmp. y.order <- c(array.order $ Array , " Unknown" )
982983 } else {
983- y.order <- array.order $ Array
984+ tmp.y.order <- array.order $ Array
985+ }
986+ }
987+
988+ if (missing(" y.order" )) {
989+ y.order <- tmp.y.order
990+ } else {
991+ check <- ! tmp.y.order %in% y.order
992+ if (any(check )) {
993+ stop(" y.order argument is missing the following required values: " ,
994+ paste(tmp.y.order [check ], collapse = " , " ),
995+ call. = FALSE )
996+ }
997+ check <- ! y.order %in% tmp.y.order
998+ if (any(check )) {
999+ warning(" y.order argument has values that will not be used: " ,
1000+ paste(y.order [check ], collapse = " , " ),
1001+ call. = FALSE , immediate. = TRUE )
1002+ y.order <- y.order [! check ]
9841003 }
9851004 }
9861005
0 commit comments