statquant
statquant

Reputation: 14370

Download data underlying plotly graph in R

I am using plotly in Rmarkdown. When I plot a graph, id there a way to download the underlying data ?

library(plotly)
x <- c(1:100)
random_y <- rnorm(100, mean = 0)
data <- data.frame(x, random_y)
p <- plot_ly(data, x = ~x, y = ~random_y, type = 'scatter', mode = 'lines')

Typically in the plot above I would like to get the data data.frame in some csv format

Upvotes: 0

Views: 1262

Answers (1)

David Klotz
David Klotz

Reputation: 2431

You can embed the CSV file into your Rmarkdown HTML using this function: yihui.name/en/2018/07/embed-file.

Upvotes: 1

Related Questions