-
Notifications
You must be signed in to change notification settings - Fork 633
/
Copy pathfigure.R
24 lines (24 loc) · 941 Bytes
/
figure.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#' Request a figure object
#'
#' Figure objects work in the same way as plotly objects, but when printed,
#' they overwrite the already existing plotly object
#' (instead of creating a new plotly).
#'
#' @param username corresponding username for the figure.
#' @param id of the Plotly figure.
#' @export
#' @references https://plot.ly/rest/
#' @examples
#' \dontrun{
#' # Anyone can obtain the information for a particular plot
#' fig <- get_figure("cpsievert", "559")
#' # If you have proper credentials, you can easily modify
#' layout(fig, title = paste("Modified on ", Sys.time()))
#' }
get_figure <- function(username, id) {
if (missing(username)) username <- verify("username")
if (missing(id)) stop("Please provide a figure id number")
base_url <- file.path(get_domain(), "apigetfile", username, id)
resp <- httr::GET(base_url, plotly_headers(), httr::config(ssl_verifypeer=FALSE))
process(struct(resp, "figure"))
}