- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
目标
我想使用横向位置数据找到图中所示车辆变道的持续时间。
数据
以下仅是一辆车的数据:
> dput(a)
structure(list(Frame.ID = 526:1058, xcoord = c(14.346, 14.367,
14.388, 14.419, 14.458, 14.503, 14.55, 14.6, 14.65, 14.702, 14.754,
14.807, 14.86, 14.913, 14.966, 15.02, 15.072, 15.125, 15.178,
15.23, 15.282, 15.333, 15.384, 15.434, 15.482, 15.529, 15.574,
15.617, 15.657, 15.694, 15.727, 15.755, 15.78, 15.802, 15.823,
15.841, 15.858, 15.874, 15.889, 15.903, 15.917, 15.93, 15.942,
15.955, 15.967, 15.978, 15.989, 16, 16.011, 16.022, 16.033, 16.044,
16.055, 16.065, 16.075, 16.085, 16.095, 16.104, 16.112, 16.12,
16.129, 16.139, 16.151, 16.164, 16.178, 16.195, 16.212, 16.231,
16.25, 16.27, 16.291, 16.312, 16.333, 16.356, 16.379, 16.403,
16.428, 16.455, 16.482, 16.511, 16.542, 16.574, 16.609, 16.646,
16.687, 16.732, 16.783, 16.839, 16.902, 16.967, 17.033, 17.1,
17.168, 17.232, 17.294, 17.354, 17.41, 17.464, 17.513, 17.559,
17.6, 17.636, 17.665, 17.685, 17.694, 17.7, 17.708, 17.725, 17.751,
17.782, 17.817, 17.856, 17.897, 17.939, 17.982, 18.025, 18.067,
18.108, 18.145, 18.178, 18.207, 18.232, 18.255, 18.274, 18.292,
18.308, 18.323, 18.336, 18.349, 18.361, 18.372, 18.383, 18.393,
18.403, 18.413, 18.422, 18.432, 18.441, 18.451, 18.46, 18.469,
18.479, 18.488, 18.496, 18.505, 18.513, 18.521, 18.529, 18.537,
18.544, 18.55, 18.556, 18.562, 18.567, 18.574, 18.58, 18.588,
18.597, 18.609, 18.623, 18.64, 18.662, 18.69, 18.722, 18.76,
18.802, 18.849, 18.899, 18.953, 19.012, 19.076, 19.144, 19.218,
19.299, 19.386, 19.479, 19.574, 19.669, 19.763, 19.855, 19.945,
20.031, 20.112, 20.187, 20.254, 20.31, 20.352, 20.385, 20.412,
20.435, 20.45, 20.455, 20.449, 20.436, 20.416, 20.39, 20.361,
20.328, 20.293, 20.256, 20.217, 20.178, 20.139, 20.1, 20.063,
20.026, 19.99, 19.957, 19.925, 19.895, 19.867, 19.842, 19.819,
19.796, 19.774, 19.751, 19.729, 19.707, 19.685, 19.662, 19.64,
19.617, 19.594, 19.571, 19.547, 19.523, 19.499, 19.473, 19.449,
19.426, 19.404, 19.382, 19.359, 19.336, 19.312, 19.288, 19.263,
19.237, 19.211, 19.184, 19.156, 19.127, 19.097, 19.066, 19.033,
18.998, 18.961, 18.921, 18.878, 18.831, 18.781, 18.727, 18.67,
18.612, 18.554, 18.498, 18.446, 18.397, 18.349, 18.304, 18.264,
18.233, 18.21, 18.194, 18.182, 18.175, 18.171, 18.17, 18.172,
18.177, 18.183, 18.192, 18.202, 18.213, 18.226, 18.241, 18.258,
18.277, 18.298, 18.321, 18.346, 18.371, 18.396, 18.422, 18.447,
18.471, 18.495, 18.518, 18.54, 18.559, 18.577, 18.591, 18.601,
18.606, 18.605, 18.6, 18.593, 18.584, 18.579, 18.58, 18.59, 18.607,
18.629, 18.655, 18.682, 18.711, 18.739, 18.766, 18.792, 18.818,
18.842, 18.864, 18.885, 18.905, 18.924, 18.943, 18.961, 18.98,
19, 19.02, 19.038, 19.054, 19.068, 19.081, 19.092, 19.103, 19.112,
19.121, 19.129, 19.137, 19.144, 19.15, 19.156, 19.161, 19.166,
19.169, 19.172, 19.173, 19.173, 19.171, 19.168, 19.163, 19.156,
19.147, 19.136, 19.123, 19.109, 19.093, 19.078, 19.061, 19.041,
19.017, 18.988, 18.954, 18.918, 18.878, 18.836, 18.795, 18.756,
18.722, 18.693, 18.671, 18.655, 18.642, 18.633, 18.625, 18.619,
18.613, 18.608, 18.602, 18.593, 18.58, 18.562, 18.537, 18.504,
18.46, 18.403, 18.33, 18.234, 18.115, 17.972, 17.806, 17.623,
17.427, 17.223, 17.013, 16.802, 16.592, 16.389, 16.191, 15.998,
15.806, 15.604, 15.386, 15.149, 14.891, 14.617, 14.328, 14.029,
13.722, 13.412, 13.097, 12.773, 12.436, 12.084, 11.723, 11.361,
11.006, 10.663, 10.334, 10.02, 9.723, 9.453, 9.219, 9.027, 8.874,
8.753, 8.657, 8.583, 8.525, 8.481, 8.448, 8.421, 8.4, 8.384,
8.371, 8.36, 8.351, 8.345, 8.338, 8.33, 8.319, 8.304, 8.284,
8.258, 8.224, 8.183, 8.136, 8.084, 8.029, 7.971, 7.912, 7.853,
7.794, 7.736, 7.681, 7.629, 7.581, 7.54, 7.506, 7.482, 7.468,
7.46, 7.459, 7.462, 7.468, 7.477, 7.489, 7.501, 7.514, 7.526,
7.539, 7.55, 7.562, 7.573, 7.584, 7.595, 7.607, 7.62, 7.636,
7.654, 7.675, 7.702, 7.734, 7.773, 7.823, 7.885, 7.96, 8.046,
8.134, 8.213, 8.278, 8.322, 8.342, 8.338, 8.308, 8.258, 8.192,
8.112, 8.023, 7.927, 7.827, 7.725, 7.623, 7.522, 7.424, 7.334,
7.252, 7.183, 7.128, 7.093, 7.078, 7.085, 7.117, 7.177, 7.267,
7.385, 7.525, 7.679, 7.839, 8, 8.155, 8.296, 8.418, 8.519, 8.606,
8.682, 8.749, 8.82, 8.891, 8.956, 9.012, 9.057, 9.09, 9.126,
9.162, 9.197, 9.227, 9.249, 9.257, 9.254, 9.251, 9.247), Lane = c(2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 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ows)]
a$difference <- abs(a$lch - a$xcoord)
Frame.ID
929(本例)向上和向下比较差异变得相似的地方。
最佳答案
不确定这是否是最好/最快的解决方案,但我们的想法是计算您创建的两个连续“差异”列之间的差异,并选择一个小值作为阈值来标记它们开始变得相似。然后为每个车道获取最接近变化时间点的行。
请注意,我将您的数据集重命名为 dt
.逐步运行该过程以查看该过程是如何工作的。如果您对它感到满意,您可以通过组合一些命令来缩短脚本。
dt$rows <- as.numeric(row.names(dt)) # Row numbers
dt$lch <- dt$xcoord[match(head(which(dt$Lane==1),1), dt$rows)]
dt$difference <- abs(dt$lch - dt$xcoord)
library(dplyr)
dt %>%
mutate(frameIDchange = Frame.ID[difference==0], # spot the frame ID of the change
diff_diff = difference - lag(difference, default=difference[1]), # find the difference of two consequtive differences
flag = ifelse(abs(diff_diff) <= 0.01,1,0)) %>% # flag if the difference of two consequtive differences is equal or less to our threshold (0.01)
filter(flag==1) %>% # keep only rows with threshold difference
mutate(frameIDdiff = abs(Frame.ID-frameIDchange)) %>% # calculate distance of frame IDs
group_by(Lane) %>% # for each lane
filter(frameIDdiff== min(abs(frameIDdiff))) # return the frame id closest to the change frame id with a difference equal or less to our threshold
# Frame.ID xcoord Lane rows lch difference frameIDchange diff_diff flag frameIDdiff
# 1 896 18.593 2 371 12.436 6.157 929 -0.009 1 33
# 2 953 8.351 1 428 12.436 4.085 929 0.009 1 24
关于r - 如何确定 R 中特定行周围的相似值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32420872/
我正在使用 Selenium Web 驱动程序 3.0,并且想要从打开的两个对话框(一个在后台,第二个在前台)的 Activity 对话框中单击“确定”按钮。如何从 html 下面的父 div 单击前
actions: [ FlatButton( onPressed: () {
我有一个问题有点超出我的范围(我真的很高兴我是 Beta)涉及重复项(所以 GROUP BY, HAVING, COUNT),通过将解决方案保留在 SQLite 附带的标准函数中而变得更加复杂。我正在
使用DBI是否可以确定SELECT语句的已执行语句句柄是否返回任何行而不从中获取行? IE。就像是: use DBI; ... my $sth = $dbh->prepare("SELECT ..."
是否可以为“确定”和“关闭”按钮指定回调函数? 如果是JQuery Modal,则可以在初始化时使用按钮字典指定回调函数。 Semantic-ui模态是否提供类似的功能?按下确定后,我该如何寻求其他逻
我想阅读警报中的消息。 示例:如果警报显示“错误的电子邮件地址”。怎么读呢?意味着我想将该消息存储在字符串中。 如何在“警报”中单击“确定”...?? 如何使用 Selenium 来做到这一点? 最佳
我有一个删除按钮: 我试图首先查明是否已选择一个网站,如果已选择一个网站,我需要确定是否已选择一个或多个列表项,如果是,则继续删除这些项目。 我的 if 语句不断返回“您必须首先选择您的列表”,即使它
部分出于好奇——我们想知道在我们的应用程序中发生了什么——部分是因为我们需要在我们的代码中找到一些潜在的问题,我喜欢在我们的网络应用程序运行时跟踪一些一般值。这尤其包括某些对象图的分配内存。 我们的应
我将 SweetAlert 与 Symfony 结合使用,我希望用户在完成删除操作之前进行确认。 发生的情况是,当用户单击删除按钮时,SweetAlert 会弹出,然后立即消失,并且该项目被删除。 在
我们有一个应用程序可以生成不包括字母 O 的随机基数 35 [0-9A-Z]。我正在寻找一种解决方案来查找包含任何淫秽英语单词的代码,而无需搜索包含 10,000 个条目的列表每个生成的代码。每秒生成
这是我做的: #include #include int betweenArray(int a, int b){ int *arr,i,range; range = b - a +
我知道如何创建 警报和确认框,但我不知道如何做的是实际单击“确定”。我有一个弹出确认框的页面。 我想使用 Java Script 插件单击“确定”。基本上,我希望我的代码单击页面上的链接,然后在出现提
代码: swal('Your ORDER has been placed Successfully!!!'); window.location="index.php"; 甜蜜警报工
>>> import re >>> s = "These are the words in a sentence" >>> regex = re.compile('are|words') >>> [m
使用确定的理想散列函数给出随机期望线性时间算法两个数组 A[1..n] 和 B[1..n] 是否不相交,即 A 的元素是否也是 B 的元素。 谁能告诉我如何做到这一点,甚至如何开始考虑它? 最佳答案
我在计算机科学课上有这段代码: int input=15; while (input < n ) { input = input *3;} 这段代码有 log3(n/15) 次循环的上限。我们怎样才能
我有一个允许 2 位玩家玩 TicTacToe 的程序。在每个玩家移动之后,它应该在那个点显示棋盘并返回一个名为 Status 的枚举,显示玩家是否应该继续,如果玩家赢了,还是平局。但是,该算法要么返
给定一个 y 值数组,例如 [-3400, -1000, 500, 1200, 3790],我如何确定“好的”Y 轴标签并将它们放置在网格上? ^ ---(6,000)-|---
假设我有一个检查用户登录的 SQL 语句: SELECT * FROM users WHERE username='test@example.com', password='abc123', expi
teradata中有返回表中哪一列被定义为主索引的命令吗?我没有制作一些我正在处理的表,也没有尝试优化我对这些表的连接。谢谢! 最佳答案 有dbc.IndicesV,其中IndexNumber=1表示
我是一名优秀的程序员,十分优秀!