[英]How can I send R code containing the % symbol to IBM dashDB?
I'm trying to send and execute an R script to the IBM dashDB REST endpoint based on the tutorial . 我正在尝试根据教程将R脚本发送并执行到IBM dashDB REST端点。
Everything works quite nice but when I use the following code 一切正常,但是当我使用以下代码时
timestamp=as.numeric(strptime(df$TIMESTAMP, \"%Y-%m-%d %H:%M:%S.000000\"));
The dashDB REST service simply returns: dashDB REST服务仅返回:
An internal error has occurred.
发生内部错误。 Please check the URL and try again.
请检查网址,然后重试。
Using the R web console inside the dashDB service the script runs fine. 使用dashDB服务中的R Web控制台,脚本可以正常运行。 I've attached the whole script at the end of this message.
我已将整个脚本附加在此消息的末尾。
Any ideas? 有任何想法吗?
library(ibmdbR)
mycon <- idaConnect("BLUDB", "", "")
idaInit(mycon)
df <- as.data.frame(ida.data.frame('"DASH110683"."TEMPERATURE"')[ ,c('NAME', 'TEMPERATURE', 'TIMESTAMP')])
pattern="%Y-%m-%d %H:%M:%S.000000"
timestamp=as.numeric(strptime(df$TIMESTAMP, pattern))
maxTimestamp=max(timestamp)
cutOffTimestamp=maxTimestamp - 10
idx = which(timestamp>cutOffTimestamp)
workingSubset=df[idx,]
devideIds=unique(workingSubset$NAME)
scores = 1:length(devideIds)
for (i in 1:length(devideIds)) {
idx = which(workingSubset$NAME==devideIds[i])
df=workingSubset[idx,]
values=as.numeric(df$TEMPERATURE)
#scores[i]=(sqrt((globalMean- mean(values))^2) +sqrt((globalSD- sd(values))^2))/2
#scores[i]=abs(globalSD- sd(values))
scores[i]=sd(values)
}
if (max(scores)>1) {
devideIdOutlier=devideIds[scores==max(scores)]
} else {
devideIdOutlier=0;
}
Romeo, the API described in the tutorial is more of a preliminary one. 罗密欧,本教程中描述的API更像是一个初步的API。 In fact we have just made available the new strategic one that also provides more options.
实际上,我们刚刚提供了新的战略计划,该战略计划也提供了更多选择。 You can now either pass in the R script via a request parameter or you can reference a R script that is stored inside dashDB (eg by using the built-in RStudio and saving the script).
现在,您可以通过请求参数传入R脚本,也可以引用存储在dashDB中的R脚本(例如,使用内置的RStudio并保存脚本)。
https://developer.ibm.com/clouddataservices/wp-content/themes/projectnext-clouddata/dashDB/ https://developer.ibm.com/clouddataservices/wp-content/themes/projectnext-clouddata/dashDB/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.