【发布时间】:2017-08-07 22:39:46
【问题描述】:
我有下表
**A** | **B** | **C** |**D** |
:----: | :----: | :----:|:----:|
1/1/17 | 3/1/17 |4/1/17 | H |
1/1/17 | 3/1/17 |4/1/17 | H |
2/1/17 | 4/1/17 |5/1/17 | V |
3/1/17 | 5/1/17 |6/1/17 | V |
4/1/17 | 5/1/17 |7/1/17 | H |
4/1/17 | 6/1/17 |7/1/17 | H |
使用R代码查找下表中的结果
1. A column with Unique list of dates from columns A,B & C above
2. A count of dates <= (less than or equal to) the unique
dates column value in each of the columns A,B & C from above table.
3. Filtered by column D value of 'H' only
结果
**Unique Dates** | **Count of A** | **Count of B** |**Count of C** |
:----: | :----: | :----: | :----: |
1/1/17 | 2 | 0 | 0 |
2/1/17 | 2 | 0 | 0 |
3/1/17 | 2 | 2 | 0 |
4/1/17 | 4 | 2 | 2 |
5/1/17 | 4 | 3 | 2 |
6/1/17 | 4 | 4 | 2 |
7/1/17 | 4 | 0 | 4 |
【问题讨论】:
-
为您的示例数据发布 dput(.) 的输出。目前标题和日期不是标准格式,表明您还没有完成正确的数据输入作业,
-
嗨@dhu,您在下面收到了一些答案。如果其中一个解决了您的问题,请考虑通过单击左侧的复选标记来接受它作为答案。这让社区知道答案有效并且您的问题应该被关闭。
标签: r date dataframe spotfire countif