基于R中的两列填充一列
我有以下数据集,并且正在尝试创建一个更有意义的路径。
行# | 会话 | 单击 | 页 |
---|---|---|---|
第1 | 123 | 123输入 | PG1 |
2 | 123 | PHPBUTTON | PG1 |
3 | 123 | ENTER | PG2 |
4 | 123 | ENTER | PG3 |
5 | 123 | form1 | pg3 |
6 | 123 | form2 | pg3 |
7 | 123 | form1 form1 | 8 |
123 | form1 | pg3 | pg3 |
9 | 123 | abcbutton | pg3 |
10 | 123 | Enter | PG1 |
pg3 | 103 | pg3 | abcbutton |
form1 | 123 | 输入 | PG4 |
13 | 123 | 输入 | PG3 |
14 | 123 | 返回 | PG3 |
15 | 123 | Enter | PG1 |
我希望结果看看以下结果:
会话 | 活动 |
---|---|
123 | PG1 |
123 | PHPBUTTON |
123 | PG2 |
123 | PG2 |
123 PG3 123 pG3 123 | form1 |
123 | form2 form2 |
123 | form2 form2 form2 form2 |
form1 form1 form1 form1 123 | abcbutton |
abcbutton 123 | PG1 123 PG1 |
123 | XYZSELECT |
123 | PG4 |
PG3 | 123 PG4 123 PG3 PG4 123 PG3 PG3 PG3 PG3 PG3 PG3 PG3 PG3 |
123 | 返回 |
123 | PG1 |
如果单击列已输入,则活动列应显示页面。但是,如果后续页面等于上一页,则“活动”列应显示“单击”列中的值。例如,第1行和第2行具有相同的页码,因此我希望活动列显示PG1,然后是PHPBUTTON。但是,如果单击列具有两个或多个后续相同值,如第7和8行所示,我希望“活动”列仅显示表格1的一个条目
。非常感谢。
I have the below dataset, and I am trying to create a more meaningful path.
Row# | Session | Click | Page |
---|---|---|---|
1 | 123 | Enter | Pg1 |
2 | 123 | phpbutton | Pg1 |
3 | 123 | Enter | Pg2 |
4 | 123 | Enter | Pg3 |
5 | 123 | Form1 | Pg3 |
6 | 123 | Form2 | Pg3 |
7 | 123 | Form1 | Pg3 |
8 | 123 | Form1 | Pg3 |
9 | 123 | abcbutton | Pg3 |
10 | 123 | Enter | Pg1 |
11 | 123 | xyzselect | Pg1 |
12 | 123 | Enter | Pg4 |
13 | 123 | Enter | Pg3 |
14 | 123 | Back | Pg3 |
15 | 123 | Enter | Pg1 |
I would like the outcome to look this:
Session | Activity |
---|---|
123 | Pg1 |
123 | phpbutton |
123 | Pg2 |
123 | Pg3 |
123 | Form1 |
123 | Form2 |
123 | Form1 |
123 | abcbutton |
123 | Pg1 |
123 | xyzselect |
123 | Pg4 |
123 | Pg3 |
123 | Back |
123 | Pg1 |
If the Click column has Enter, then the Activity column should show the Page. But, if the subsequent page is equal to the previous page, then the Activity column should show the value from the Click column. For instance, row# 1 and 2 have the same Page numbers, so I would like the Activity column to show, Pg1, then, phpbutton. But, if the Click column has two or more subsequent same values, as seen in Row# 7 and 8, I would like the Activity column to show just one entry of Form 1.
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试一下
Try this
您可以删除类似的重复,连续行:
数据:
You could remove duplicate, consecutive rows like this:
data: