File: df_to_d3json.R

package info (click to toggle)
r-cran-ggvis 0.4.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,716 kB
  • sloc: sh: 25; makefile: 2
file content (13 lines) | stat: -rw-r--r-- 325 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
# Convert a data object to a D3-structured data object.
df_to_d3json <- function(x) {
  rows <- nrow(x)
  colnames <- stats::setNames(names(x), names(x))

  x <- lapply(x, format_vec_d3json)

  lapply(seq_len(rows), function(i) {
    lapply(colnames, function(colname) {
      .subset2(.subset2(x, colname), i)
    })
  })
}