plotly_data

0th

Percentile

Obtain data associated with a plotly graph

plotly_data() returns data associated with a plotly visualization (if there are multiple data frames, by default, it returns the most recent one).

Usage
plotly_data(p, id = p$x$cur_data)

# S3 method for plotly groups(x)

# S3 method for plotly ungroup(x, ...)

# S3 method for plotly group_by_(.data, ..., .dots, add = FALSE)

# S3 method for plotly summarise_(.data, ..., .dots)

# S3 method for plotly mutate_(.data, ..., .dots)

# S3 method for plotly arrange_(.data, ..., .dots)

# S3 method for plotly select_(.data, ..., .dots)

# S3 method for plotly filter_(.data, ..., .dots)

# S3 method for plotly distinct_(.data, ..., .dots)

# S3 method for plotly slice_(.data, ..., .dots)

# S3 method for plotly rename_(.data, ..., .dots)

# S3 method for plotly transmute_(.data, ..., .dots)

Arguments
p

a plotly visualization

id

a character string or number referencing an "attribute layer".

x

a plotly visualization

...

stuff passed onto the relevant method

.data

a plotly visualization

.dots

Used to work around non-standard evaluation. See vignette("nse") for details

add

By default, when add = FALSE, group_by will override existing groups. To instead add to the existing groups, use add = TRUE

Aliases
  • arrange_.plotly
  • distinct_.plotly
  • filter_.plotly
  • group_by_.plotly
  • groups.plotly
  • mutate_.plotly
  • plotly_data
  • rename_.plotly
  • select_.plotly
  • slice_.plotly
  • summarise_.plotly
  • transmute_.plotly
  • ungroup.plotly
Examples
library(plotly) # NOT RUN { # use group_by() to define groups of visual markings p <- txhousing %>% group_by(city) %>% plot_ly(x = ~date, y = ~sales) p # plotly objects preserve data groupings groups(p) plotly_data(p) # dplyr verbs operate on plotly objects as if they were data frames p <- economics %>% plot_ly(x = ~date, y = ~unemploy / pop) %>% add_lines() %>% mutate(rate = unemploy / pop) %>% filter(rate == max(rate)) plotly_data(p) add_markers(p) layout(p, annotations = list(x = ~date, y = ~rate, text = "peak")) # use group_by() + do() + subplot() for trellis displays d <- group_by(mpg, drv) plots <- do(d, p = plot_ly(., x = ~cty, name = ~drv)) subplot(plots[["p"]], nrows = 3, shareX = TRUE) # arrange displays by their mean means <- summarise(d, mn = mean(cty, na.rm = TRUE)) means %>% dplyr::left_join(plots) %>% arrange(mn) %>% subplot(nrows = NROW(.), shareX = TRUE) # more dplyr verbs applied to plotly objects p <- mtcars %>% plot_ly(x = ~wt, y = ~mpg, name = "scatter trace") %>% add_markers() p %>% slice(1) %>% plotly_data() p %>% slice(1) %>% add_markers(name = "first observation") p %>% filter(cyl == 4) %>% plotly_data() p %>% filter(cyl == 4) %>% add_markers(name = "four cylinders") # }
Documentation reproduced from package plotly, version 4.5.2, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.