File: compare_options.R

package info (click to toggle)
r-cran-manipulatewidgets 0.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,992 kB
  • sloc: makefile: 2
file content (49 lines) | stat: -rw-r--r-- 1,646 bytes parent folder | download | duplicates (2)
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
40
41
42
43
44
45
46
47
48
49
#' Options for comparison mode
#'
#' This function generates a list of options that are used by
#' \code{\link{manipulateWidget}} to compare multiple charts.
#'
#' @param ncharts Number of charts to generate.
#' @param nrow Number of rows. If \code{NULL}, the function tries to pick the
#'   best number of rows given the number of charts and columns.
#' @param ncol Number of columns. If \code{NULL}, the function tries to pick the
#'   best number of columns given the number of charts and rows.
#'
#' @return List of options
#'
#' @examples
#' if (require(dygraphs)) {
#'
#'   mydata <- data.frame(
#'     year = 2000+1:100,
#'     series1 = rnorm(100),
#'     series2 = rnorm(100),
#'     series3 = rnorm(100)
#'   )
#'   manipulateWidget(
#'     dygraph(mydata[range[1]:range[2] - 2000, c("year", series)], main = title),
#'     range = mwSlider(2001, 2100, c(2001, 2100)),
#'     series = mwSelect(c("series1", "series2", "series3")),
#'     title = mwText("Fictive time series"),
#'     .compare = list(title = NULL, series = NULL),
#'     .compareOpts = compareOptions(ncharts = 4)
#'   )
#'
#'   manipulateWidget(
#'     dygraph(mydata[range[1]:range[2] - 2000, c("year", series)], main = title),
#'     range = mwSlider(2001, 2100, c(2001, 2100)),
#'     series = mwSelect(c("series1", "series2", "series3")),
#'     title = mwText("Fictive time series"),
#'     .compare = list(title = NULL, series = NULL),
#'     .compareOpts = compareOptions(ncharts = 3, nrow = 3)
#'   )
#' }
#'
#' @export
compareOptions <- function(ncharts = NULL, nrow = NULL, ncol = NULL) {
  list(
    ncharts = ncharts,
    nrow = nrow,
    ncol = ncol
  )
}