【发布时间】:2019-05-14 13:42:43
【问题描述】:
我在 R 中创建了一个函数 Input,以根据日期参数 Date1 和 Date2 绘制图表。该函数在 R 中成功运行并提供所需的输出。接下来,我尝试通过向 URL 提供 curl 命令和函数参数来在 OpenCPU 上执行相同的操作。此时,指令失败并出现错误。
我正在尝试传递这样的参数:
curl http://localhost:5656/ocpu/library/InputParam/R/Input -d '{"Date1": "2018-04-25 05:45:00" & "Date2": "2018-05-27 21:45:00 AM"}'
error : unused argument (`'{Date1:` = NA)
In call:
Input(`'{Date1:` = NA)
curl: (3) URL using bad/illegal format or missing URL
'"Date2":' is not recognized as an internal or external command,
operable program or batch file.
这是功能代码:
Input <- function (Date1,Date2){
library('dplyr')
library('lubridate')
test <- data[data$ShiftStartTime >= Date1 & data$ShiftEndTime <= Date2,]
library('plotly')
p <- plot_ly(test, x = ~test$Equip, y = ~test$DTDuration, name = test$Description) %>%
add_trace(y = ~test$DTDuration, name = test$Description) %>%
layout(yaxis = list(title = 'DTDuration'), barmode = 'stack')
p
}
library('opencpu')
ocpu_start_server()`
类似这样的:
curl https://cloud.opencpu.org/ocpu/tmp/x0468b7ab/graphics/last/png
curl https://cloud.opencpu.org/ocpu/tmp/x0468b7ab/graphics/1/png?width=1000
curl https://cloud.opencpu.org/ocpu/tmp/x0468b7ab/graphics/last/svg
curl https://cloud.opencpu.org/ocpu/tmp/x0468b7ab/graphics/last/pdf?width=8`
【问题讨论】:
-
也许将字符串日期转换为函数开头的日期?
-
嗨.. 感谢您的回复。我尝试过这种方式,但它不起作用。