简体   繁体   English

当我需要在Tableau中传递分类数据时,如何从R中检索聚合度量?

[英]How do I retrieve aggregate measures from R when I need to pass disaggregated data in Tableau?

I have extensively read and re-read the Troubleshooting R Connections and Tableau and R Integration help documents, but as a new Tableau user they just aren't helping me. 我已经广泛阅读并重新阅读了《 R连接疑难解答》以及Tableau和R Integration帮助文档,但是作为Tableau的新用户,他们只是没有帮助。

I need to be able to calculate Kaplan-Meier survival probabilities across any dimensions that are dragged onto the sheet. 我需要能够计算拖到图纸上的任何维度上的Kaplan-Meier生存概率。 Ideally, I would be able to retrieve this in a tabular format at multiple time points, but for now, I would be happy just to get it at a single time point. 理想情况下,我可以在多个时间点以表格格式检索此内容,但是现在,我很乐意仅在单个时间点获取它。

My data in Tableau have columns for [event-boolean] and [time to event]. 我在Tableau中的数据具有[event-boolean]和[time to event]的列。 Let's say I also have columns for Gender and District. 假设我也有“性别”和“地区”专栏。

Currently, I have a calculated field [surv] as: 目前,我有一个计算字段[surv]为:

SCRIPT_REAL('
library(survival);
fit <- summary(survfit(Surv(.arg2,.arg1) ~ 1), times=365);
fit$surv'
,  min([event-boolean])
,  min([time to event])
)

I have messed with Computed Using, Addressing, Partitions, Aggregate Measures, and parameters to the R function, but no combination I have tried has worked. 我对R函数的计算使用,寻址,分区,汇总度量和参数感到困惑,但是我尝试过的任何组合都没有用。

If [District] is in Columns, do I need to change my SCRIPT_REAL call or do I just need to change some other combination of levers? 如果[District]在“ Columns”中,我是否需要更改SCRIPT_REAL调用或仅需要更改一些其他杠杆组合?

I used Andrew's solution to solve this problem. 我使用安德鲁的解决方案来解决此问题。 Essentially, 实质上,
- Turn off Aggregate Measures -关闭汇总措施
- In the Measure Values shelf, select Compute Using > Cell -在“测量值”架子中,选择“计算方式”>“单元格”
- In the calculated field, start with If FIRST() == 0 script_*() END -在计算字段中,以If FIRST() == 0 script_*() END
- Ctrl+drag the measure to the Filters shelf and use a Special > Non-null filter. -Ctrl +将度量拖动到“过滤器”架子,然后使用“特殊”>“非空”过滤器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM