File: develop_advanced.R

package info (click to toggle)
r-cran-htmlwidgets 1.6.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 516 kB
  • sloc: javascript: 597; sh: 13; makefile: 2
file content (58 lines) | stat: -rw-r--r-- 2,630 bytes parent folder | download
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
50
51
52
53
54
55
56
57
58
## ----echo=FALSE, comment=''---------------------------------------------------
htmlwidgets:::toJSON2(head(iris, 3), pretty = TRUE)

## ----echo=FALSE, comment=''---------------------------------------------------
htmlwidgets:::toJSON2(head(iris, 3), dataframe = 'row', pretty = TRUE)

## ----echo=FALSE, comment=''---------------------------------------------------
htmlwidgets:::toJSON2(unname(head(iris, 8)), dataframe = 'column', pretty = TRUE)

## ----echo=FALSE, comment=''---------------------------------------------------
htmlwidgets:::toJSON2(head(iris, 8), dataframe = 'values', pretty = TRUE)

## ----eval=FALSE, code=head(capture.output(htmlwidgets:::toJSON2),-1), tidy=FALSE----
#  function (x, ..., dataframe = "columns", null = "null", na = "null",
#      auto_unbox = TRUE, digits = getOption("shiny.json.digits",
#          16), use_signif = TRUE, force = TRUE, POSIXt = "ISO8601",
#      UTC = TRUE, rownames = FALSE, keep_vec_names = TRUE, strict_atomic = TRUE)
#  {
#      if (strict_atomic)
#          x <- I(x)
#      jsonlite::toJSON(x, dataframe = dataframe, null = null, na = na,
#          auto_unbox = auto_unbox, digits = digits, use_signif = use_signif,
#          force = force, POSIXt = POSIXt, UTC = UTC, rownames = rownames,
#          keep_vec_names = keep_vec_names, json_verbatim = TRUE,
#          ...)
#  }
#  <bytecode: 0x12281ff40>

## ----eval=FALSE---------------------------------------------------------------
#  fooWidget <- function(data, name, ...) {
#    # ... process the data ...
#    params <- list(foo = data, bar = TRUE)
#    # customize toJSON() argument values
#    attr(params, 'TOJSON_ARGS') <- list(digits = 7, na = 'string')
#    htmlwidgets::createWidget(name, x = params, ...)
#  }

## ----eval=FALSE---------------------------------------------------------------
#  fooWidget <- function(data, name, ..., JSONArgs = list(digits = 7)) {
#    # ... process the data ...
#    params <- list(foo = data, bar = TRUE)
#    # customize toJSON() argument values
#    attr(params, 'TOJSON_ARGS') <- JSONArgs
#    htmlwidgets::createWidget(name, x = params, ...)
#  }

## ----eval=FALSE---------------------------------------------------------------
#  options(htmlwidgets.TOJSON_ARGS = list(digits = 7, pretty = TRUE))

## ----eval=FALSE---------------------------------------------------------------
#  fooWidget <- function(data, name, ...) {
#    # ... process the data ...
#    params <- list(foo = data, bar = TRUE)
#    # customize the JSON serializer
#    attr(params, 'TOJSON_FUNC') <- MY_OWN_JSON_FUNCTION
#    htmlwidgets::createWidget(name, x = params, ...)
#  }