I would like to avoid having to manually change the dates in the title of a Spotfire dashboard every week. The goal is to get every Sunday's date in short format: so in the case of this week, the title would read "As of 1/14/2018". I tried to link the expression in the title to the below R script to no avail:
d <- as.Date( Sys.Date() )
prev.days <- seq( d - 6, d ,by = 'day' )
Sunday <- prev.days[weekdays(prev.days) =='Sunday']
The chunk of code above is linked to a Document Property called Sundays. When I try to insert the document property in the title as such 'As of ${Sundays}', Spotfire detects a conversion issue:
"Error in FUN(X[[i]]) : inherits(funValue, "POSIXct") is not TRUE'.
I also tried forcing a conversion by using as.POSIXct()
in the script to no avail. I would like to avoid using R packages like lubridate as they seem buggy when used in tandem with Spotfire.
Finally, if you know a way to bypass R and write a code in Spotfire's native language that would be even better.
答案 0 :(得分:0)
尝试使用一个小编辑(添加为.POSIXct)
尝试使用您的脚本d <- as.Date( Sys.Date() )
prev.days <- seq( d - 6, d ,by = 'day' )
Sunday <- as.POSIXct(prev.days[weekdays(prev.days) =='Sunday'])
我将Sunday设置为DocumentProperty的输出参数,然后将DocumentProperty添加到标题栏。全部按预期显示,例如&#34; 01/21/2018 07:00:00&#34;以DateTime格式。据我了解,TERR将始终以类型DateTime格式发送结果。
如果没有as.POSIXct转换,TERR会将值作为Real传递给Spotfire。
转到此处了解有关TERR和日期时间的更多详细信息:https://support.tibco.com/s/article/What-TERR-object-class-does-the-Spotfire-data-function-framework-recognize-as-date-time-information?_ga=2.117439810.555218220.1516612347-1562366391.1506414681