我正在做一个调查数据集,我有来自不同国家(第1列)的人的答案(第2列)。
| 第1栏|第2栏|
| - ------|- ------|
| 中国|答案A|
| 中国|答案B|
| 法国|答案A|
| 法国|答案C|
| 意大利|答案B|
我的闪亮应用程序(https://aurelienmaignant.shinyapps.io/shiny/)显示曲线,并允许用户按国家过滤(React图)。
我想创建一个图,其中只显示col 2中至少被所有选定国家(col 1)共享一次的值。
例如,如果用户在shiny中选择“中国”和“法国,”则绘图输出应仅显示“答案A”(因为答案A至少由来自法国的某人回答一次,并且至少由来自中国的某人回答一次).
如果shiny中的用户选择“中国”、“法国”和“意大利,”则输出应该是“无,”因为三个答案(A、B或C)中没有一个被来自每个国家的人至少共享一次.
谢谢你的帮忙
1条答案
按热度按时间v9tzhpje1#
欢迎来到SO社区,下次请发一个minimal reproducible example,这样其他人就可以更好地帮助你!
我已经做了一个迷你应用程序,为你做的工作:
在服务器端,我根据用户选择的国家筛选数据集,然后使用
intersect()
,我们可以根据第一列找到第二列中的共同值。关于这一行的更多细节,您可以查看此SO post here,了解它是如何完成的。