Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何显示两列与相应日期的相交?_R_Google Analytics_Google Analytics Api - Fatal编程技术网

R 如何显示两列与相应日期的相交?

R 如何显示两列与相应日期的相交?,r,google-analytics,google-analytics-api,R,Google Analytics,Google Analytics Api,这三列是日期、第二页和退出页。 我想在secondpage列和exitpage列中显示带有相应日期的公共值 我使用了intersect(col1,col2) 但我也想显示日期 日期--第二页--退出页面 27/09------主页------主页 2009年9月28日------登陆页-----------主页 2009年9月29日------联系我们-----------------关于我们 2009年9月30日-----关于-----关于 我需要输出为 日期--第二页--退出页面 27/09

这三列是日期、第二页和退出页。 我想在secondpage列和exitpage列中显示带有相应日期的公共值

我使用了intersect(col1,col2)
但我也想显示日期

日期--第二页--退出页面 27/09------主页------主页
2009年9月28日------登陆页-----------主页
2009年9月29日------联系我们-----------------关于我们
2009年9月30日-----关于-----关于

我需要输出为

日期--第二页--退出页面 27/09------主页------主页

2009年9月30日------aboutus-----------------aboutus

这是一个使用
数据的解决方案。表

我首先生成了示例数据

dt<-data.table("date" = c("27/09","28/09","29/09","30/09"),
               "secondpage" = c("homepage","landingpage","contactus","aboutus"),
               "exitpage" = c("homepage","homepage","aboutus","aboutus"))

> dt
    date  secondpage exitpage
1: 27/09    homepage homepage
2: 28/09 landingpage homepage
3: 29/09   contactus  aboutus
4: 30/09     aboutus  aboutus
dt
日期第二页退出页
1:27/09主页
2:28/09登陆页面主页
3:29/09联系我们关于
4:30/09关于关于关于关于
下面的代码应该为您提供所需的输出

dt_res<-dt[secondpage == exitpage]

> dt_res
    date secondpage exitpage
1: 27/09   homepage homepage
2: 30/09    aboutus  aboutus
dt_res dt_res
日期第二页退出页
1:27/09主页
2:30/09关于关于关于关于
另一种选择是,不使用数据表

dt_res<-dt[dt$secondpage == dt$exitpage,]

dtu resprece不要发布代码/数据/错误的图像:它无法复制或搜索(SEO),它会破坏屏幕阅读器,并且可能不适合某些移动设备。Ref:x[x$secondPagePath==x$exitPagePath,]
?从
data.table
解决方案中,不需要使用
(date,secondpage,exitpage)
,因为默认情况下返回所有列。在基本解决方案中,
是完全不必要的。