Skip to content

Commit 46e6ce5

Browse files
committed
Follow best practices and consistency
1 parent 7797736 commit 46e6ce5

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

R/plotly.R

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -130,36 +130,35 @@ For more help, see https://plot.ly/R or contact <[email protected]>.")
130130
}
131131
}
132132
pub$get_figure <- function(file_owner, file_id) {
133-
headers = c("plotly-username"=pub$username,
134-
"plotly-apikey"=pub$key,
135-
"plotly-version"=pub$version,
136-
"plotly-platform"="R")
137-
response_handler = basicTextGatherer()
138-
header_handler = basicTextGatherer()
139-
curlPerform(url=paste("https://plot.ly/apigetfile", file_owner, file_id, sep="/"),
133+
headers <- c("plotly-username"=pub$username,
134+
"plotly-apikey"=pub$key,
135+
"plotly-version"=pub$version,
136+
"plotly-platform"="R")
137+
response_handler <- basicTextGatherer()
138+
header_handler <- basicTextGatherer()
139+
curlPerform(url=paste("https://plot.ly/apigetfile", file_owner, file_id,
140+
sep="/"),
140141
httpheader=headers,
141142
writefunction=response_handler$update,
142-
headerfunction = header_handler$update)
143-
resp_header = as.list(parseHTTPHeader(header_handler$value()))
144-
143+
headerfunction=header_handler$update)
144+
resp_header <- as.list(parseHTTPHeader(header_handler$value()))
145+
145146
# Parse status
146147
if (resp_header$status != "200") {
147-
print(resp_header$statusMsg)
148-
stop(resp_header$status)
148+
cat(resp_header$statusMsg)
149+
stop(resp_header$status)
149150
}
150-
151-
body_string = response_handler$value()
152-
resp = RJSONIO::fromJSON(body_string)
151+
152+
body_string <- response_handler$value()
153+
resp <- RJSONIO::fromJSON(body_string)
153154
if (!is.null(resp$error) && resp$error != "")
154155
stop(resp$err)
155156
if (!is.null(resp$warning) && resp$error != "")
156157
cat(resp$warning)
157158
if (!is.null(resp$message) && resp$error != "")
158159
cat(resp$message)
159-
160-
fig = resp$payload$figure
161-
162-
return(fig)
160+
161+
fig <- resp$payload$figure
163162
}
164163
pub$iplot <- function(..., kwargs = list(filename = NULL, fileopt = NULL)) {
165164
# Embed plotly graphs as iframes for knitr documents

0 commit comments

Comments
 (0)