diff --git a/R/trafficlight.R b/R/trafficlight.R index 50bd99d576a8fc4dea338a6618de5286f1f2ee4f..43cee0bb7669d9fcaaa744498fb39698894d9f08 100644 --- a/R/trafficlight.R +++ b/R/trafficlight.R @@ -8,14 +8,8 @@ #' @param time vector of time units that will be used for the x axis. #' @param sort_5yrmean logical; should the variables be sorted by the first 5yr mean? Default #' is set to TRUE. -#' @param sort_vec If specific order of variable is desired the sorting index should be +#' @param sort_vec integer vector; if specific order of variable is desired the sorting index should be #' provided here. -#' @param main A title. -#' @param xlab The x axis title. Default is none. -#' @param ylab The y axis title. Default is none. -#' @param adj_xlab integer; vertical adjustment of the x axis title. -#' @param adj_ylab integer; horizontal adjustment of the y axis title. -#' @param cols A character vector with colors for each quantile or interval. #' @param method character; the type of methods to create the color code. Choose #' between using "quantiles" (default) or "intervals". #' @param probs a vector of probabilities to calculate the quantiles using the function @@ -25,10 +19,16 @@ #' @param quantile_type an integer between 1 and 9 selecting one of the nine quantile #' algorithms detailed below to be used. Default is 7 (see also \code{\link{quantile}}). #' @param intervals logical; number of evenly-spaced intervals. Default is 5. +#' @param cols a character vector with colors for each quantile or interval. +#' @param main a title. +#' @param xlab The x axis title. Default is none. +#' @param ylab The y axis title. Default is none. +#' @param adj_xlab integer; vertical adjustment of the x axis title. +#' @param adj_ylab integer; horizontal adjustment of the y axis title. #' @param hadj_x double; horizontal adjustment of the x labels. #' @param vadj_x double; vertical adjustment of the x labels. -#' @param hadj_y double; horizontal adjustment of the x labels. -#' @param vadj_y double; vertical adjustment of the x labels. +#' @param hadj_y double; horizontal adjustment of the y labels. +#' @param vadj_y double; vertical adjustment of the y labels. #' @param madj_bottom double; adjustment of bottom margin relative to the #' current setting. #' @param madj_left double; adjustment of left margin relative to the @@ -58,20 +58,19 @@ #' @param respect logical; this argument controls whether a unit column-width is the #' same physical measurement on the device as a unit row-height (default is TRUE). #' -#' #' @export +#' @author Saskia A. Otto #' @examples -#' df <- data.frame(aaaaaaaa = 1:20, bbbbbbbbbb= rnorm(20, 100, 30), c = 1:20 + rnorm(20)) +#' df <- data.frame(variable1 = 1:20, variable2= rnorm(20, 100, 30), variable3 = 1:20 + rnorm(20)) #' trafficlight(x = df, time = 1981:2000) #' df <- matrix(rnorm(100), ncol = 5) #' colnames(df) <- letters[1:5] #' trafficlight(x = df, time = 1981:2000, legend_pos = "bottom", method = "intervals") trafficlight <- function(x, time = NULL, sort_5yrmean = TRUE, sort_vec = NULL, - main = "", xlab = "", ylab = "", adj_xlab = NULL, adj_ylab = NULL, + method = "quantiles", probs = seq(0, 1, 0.2), quantile_type = 7, intervals = 5, cols = c("green", "yellowgreen", "yellow", "gold", "red"), - method = "quantiles", - probs = seq(0, 1, 0.2), quantile_type = 7, intervals = 5, + main = "", xlab = "", ylab = "", adj_xlab = NULL, adj_ylab = NULL, hadj_x = 0.5, vadj_x = -0.7, hadj_y = -0.7, vadj_y = 0.3, madj_bottom = 0, madj_left = 0, madj_top = 0, madj_right = 0, legend_pos = "top", legend_intersp_x = 1, legend_intersp_y = 1, diff --git a/man/trafficlight.Rd b/man/trafficlight.Rd index 316f733988f862d14068de548effccab1e20400a..7c1be8e46954073f060d85c1c3da954691a49af8 100644 --- a/man/trafficlight.Rd +++ b/man/trafficlight.Rd @@ -9,16 +9,16 @@ trafficlight( time = NULL, sort_5yrmean = TRUE, sort_vec = NULL, + method = "quantiles", + probs = seq(0, 1, 0.2), + quantile_type = 7, + intervals = 5, + cols = c("green", "yellowgreen", "yellow", "gold", "red"), main = "", xlab = "", ylab = "", adj_xlab = NULL, adj_ylab = NULL, - cols = c("green", "yellowgreen", "yellow", "gold", "red"), - method = "quantiles", - probs = seq(0, 1, 0.2), - quantile_type = 7, - intervals = 5, hadj_x = 0.5, vadj_x = -0.7, hadj_y = -0.7, @@ -49,21 +49,9 @@ trafficlight( \item{sort_5yrmean}{logical; should the variables be sorted by the first 5yr mean? Default is set to TRUE.} -\item{sort_vec}{If specific order of variable is desired the sorting index should be +\item{sort_vec}{integer vector; if specific order of variable is desired the sorting index should be provided here.} -\item{main}{A title.} - -\item{xlab}{The x axis title. Default is none.} - -\item{ylab}{The y axis title. Default is none.} - -\item{adj_xlab}{integer; vertical adjustment of the x axis title.} - -\item{adj_ylab}{integer; horizontal adjustment of the y axis title.} - -\item{cols}{A character vector with colors for each quantile or interval.} - \item{method}{character; the type of methods to create the color code. Choose between using "quantiles" (default) or "intervals".} @@ -77,13 +65,25 @@ algorithms detailed below to be used. Default is 7 (see also \code{\link{quantil \item{intervals}{logical; number of evenly-spaced intervals. Default is 5.} +\item{cols}{a character vector with colors for each quantile or interval.} + +\item{main}{a title.} + +\item{xlab}{The x axis title. Default is none.} + +\item{ylab}{The y axis title. Default is none.} + +\item{adj_xlab}{integer; vertical adjustment of the x axis title.} + +\item{adj_ylab}{integer; horizontal adjustment of the y axis title.} + \item{hadj_x}{double; horizontal adjustment of the x labels.} \item{vadj_x}{double; vertical adjustment of the x labels.} -\item{hadj_y}{double; horizontal adjustment of the x labels.} +\item{hadj_y}{double; horizontal adjustment of the y labels.} -\item{vadj_y}{double; vertical adjustment of the x labels.} +\item{vadj_y}{double; vertical adjustment of the y labels.} \item{madj_bottom}{double; adjustment of bottom margin relative to the current setting.} @@ -134,9 +134,12 @@ This function creates for multiple time series an image plot where the color code is based on selected quantiles or evenly spaced intervals. } \examples{ -df <- data.frame(aaaaaaaa = 1:20, bbbbbbbbbb= rnorm(20, 100, 30), c = 1:20 + rnorm(20)) +df <- data.frame(variable1 = 1:20, variable2= rnorm(20, 100, 30), variable3 = 1:20 + rnorm(20)) trafficlight(x = df, time = 1981:2000) df <- matrix(rnorm(100), ncol = 5) colnames(df) <- letters[1:5] trafficlight(x = df, time = 1981:2000, legend_pos = "bottom", method = "intervals") } +\author{ +Saskia A. Otto +}