R/df_to_d3json.R

Defines functions df_to_d3json

# 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)
    })
  })
}

Try the ggvis package in your browser

Any scripts or data that you put into this service are public.

ggvis documentation built on May 29, 2024, 1:12 a.m.