如何在 SpotfireTitles 中动态更新日期
How to dynamically update dates in SpotfireTitles
我想避免每周手动更改 Spotfire 仪表板标题中的日期。目标是以短格式获取每个星期日的日期:因此在本周的情况下,标题将显示为 "As of 1/14/2018"。
我试图 link 下面 R 脚本标题中的表达式无济于事:
d <- as.Date( Sys.Date() )
prev.days <- seq( d - 6, d ,by = 'day' )
Sunday <- prev.days[weekdays(prev.days) =='Sunday']
上面的代码块 linked 到名为 Sundays 的文档 属性。当我尝试在标题 'As of ${Sundays}' 中插入文档 属性 时,Spotfire 检测到转换问题:
"Error in FUN(X[[i]]) : inherits(funValue, "POSIXct") is not TRUE'.
我也尝试过在脚本中使用 as.POSIXct()
强制转换,但无济于事。我想避免使用像 lubridate 这样的 R 包,因为它们在与 Spotfire 一起使用时看起来有问题。
最后,如果你知道绕过 R 并用 Spotfire 的本地语言编写代码的方法,那就更好了。
刚刚对您的脚本进行了一次小修改(添加 as.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 添加到标题栏。全部按预期显示,例如日期时间格式的“01/21/2018 07:00:00”。据我了解,TERR 将始终以 DateTime 格式发送结果。
如果不进行 as.POSIXct 转换,TERR 会将值作为 Real 传递给 Spotfire。
转到此处了解有关 TERR 和 DateTime 的更多详细信息: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
我想避免每周手动更改 Spotfire 仪表板标题中的日期。目标是以短格式获取每个星期日的日期:因此在本周的情况下,标题将显示为 "As of 1/14/2018"。 我试图 link 下面 R 脚本标题中的表达式无济于事:
d <- as.Date( Sys.Date() )
prev.days <- seq( d - 6, d ,by = 'day' )
Sunday <- prev.days[weekdays(prev.days) =='Sunday']
上面的代码块 linked 到名为 Sundays 的文档 属性。当我尝试在标题 'As of ${Sundays}' 中插入文档 属性 时,Spotfire 检测到转换问题:
"Error in FUN(X[[i]]) : inherits(funValue, "POSIXct") is not TRUE'.
我也尝试过在脚本中使用 as.POSIXct()
强制转换,但无济于事。我想避免使用像 lubridate 这样的 R 包,因为它们在与 Spotfire 一起使用时看起来有问题。
最后,如果你知道绕过 R 并用 Spotfire 的本地语言编写代码的方法,那就更好了。
刚刚对您的脚本进行了一次小修改(添加 as.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 添加到标题栏。全部按预期显示,例如日期时间格式的“01/21/2018 07:00:00”。据我了解,TERR 将始终以 DateTime 格式发送结果。
如果不进行 as.POSIXct 转换,TERR 会将值作为 Real 传递给 Spotfire。
转到此处了解有关 TERR 和 DateTime 的更多详细信息: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