提问人:Chris Ruehlemann 提问时间:7/19/2023 更新时间:7/19/2023 访问量:26
按组和间隔左连接数据帧
Left join data frames by group and interval
问:
我需要按组划分两个数据帧(分组变量是),但使用此代码我收到此错误:interval_left_join
File
library(BiocManager)
library(fuzzyjoin)
df1 %>%
group_by(File) %>%
interval_left_join(.,
df2,
by = c("Endtime_ms", "Starttime_ms"))
Error in .width_as_unnamed_integer(width, msg = "an end that is greater or equal to its start minus one") :
each range must have an end that is greater or equal to its start minus one
我已经检查过:
df2 %>% filter((Endtime_ms - Starttime_ms) < 1)
但是没有这样的行。这里出了什么问题,如何避免错误?
数据:
df1 <- structure(list(File = c("F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F16", "F16", "F16",
"F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16",
"F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16",
"F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16"
), Starttime_ms = c(282737L, 285346L, 287201L, 287339L, 288005L,
288909L, 289316L, 289389L, 291943L, 291958L, 291961L, 292298L,
292498L, 292600L, 294446L, 295671L, 297272L, 297794L, 299650L,
300935L, 301832L, 303100L, 303235L, 303586L, 305445L, 307329L,
307540L, 311383L, 311767L, 311826L, 335088L, 335647L, 336490L,
339435L, 339440L, 339445L, 340319L, 343288L, 344880L, 345235L,
347762L, 347958L, 349482L, 350240L, 351592L, 352045L, 352710L,
353223L, 355935L, 357778L, 361413L, 363835L, 365470L, 365671L,
366911L, 367650L, 369424L, 369550L, 369694L, 370864L), Endtime_ms = c(287201,
287339, 288005, 289316, 288909, 289389, 292498, 291943, 291958,
292298, 292293, 292600, 294446, 3e+05, 295671, 297272, 297794,
301321, 303100, 301617, 302120, 303586, 305445, 307329, 307321,
307540, 311383, 311767, 312054, 314075, 336134, 335930, 338980,
340319, 339700, 346995, 343288, 345170, 345261, 346111, 352678,
349008, 350202, 350927, 352024, 352528, 353074, 357252, 359958,
360286, 364993, 365264, 366411, 366815, 368423, 369127, 370533,
374517, 370435, 373317), Utterance = c("=[like] no::rmally how it happens so it 's happened <in the> Hauptbahnhof a lot, ",
"((m: points outward with right thumb, beat on \"Hauptbahnhof\")) ",
"(0.804)", "((m: both h moving in alternation palm outward)) ",
"because like tho:s:e ", "(0.480)", "((m: both h kept palm down at chest height, slight beat on \"train station\")) ",
"I don 't know if you have ever used that bathroom, in the train station¿= ",
"(0.015)", "=[no] ", "=[no] ", "(0.302)", "((m: both h palms toward face, alternating movement)) ",
"it 's (.) ↑!it! is↑ kind o:f: you ha- it 's not intuitive which one 's the mens' which one 's the womens' like you need to really like <read the si:[gn>] ",
"((m: both h palm to face at neck height first move circularly toward chin then back)) ",
"((m: both hands, first right then left, rotate around wrist)) ",
"((m: both h rotate toward face)) ", "((m & h: head moves forward and back while both h palm outward fingers spread first approach face, then form ring like binoculars and move outward)) ",
"[oh the one] you have to pay to [enter¿ like one] euro [or something] °yeah yeah° ",
"[yeah =yeah =yeah =yeah] ", "[!yeah!] ", "(0.486)", "((m: both arms 'open up' moving laterally, then both h flex inward twice)) ",
"and like IT 'S AN OPEN entrance on either end (.) I get it you go in the wrong end ",
"((m: both h palms open at chest height, circular movement twice)) ",
"(0.211)", "u::m (.) I was going in one day and the cleaning woman there !stopp!ed me >she was like< ",
"(0.384)", "~er~ ", "((m: left h held laterally at knee height)) ",
"[oh] yeah [((v: laughs))] ", "[u:m] ", "like (.) he applied, to become a diplomat ",
"((m: b h grabs r thumb with l h @loct)) ", "[yeah] ", "[!got!] accepted starts with diplomatic (.) schooling like he goes through the whole thing which is [!really! h]ard like I 'm I 'm not even attempting it ",
"((m: b h grabs r index with l h @loct)) ", "((m: b h open palms facing in @peri)) ",
"[right] ", "((m: b h open palms points to self @ctct)) ", "RIGHT this is [like to join the foreign] service, [right¿] [I think it takes like] three years [does n't it] °to [do everything°]= ",
"[cos I think you sh-] ", "[yeah ex]actly= ", "=[yeah] ", "[yeah]= ",
"=[°yeah°]= ", "=°yeah°= ", "=u:m and then they had a ↑budget↑ cut (.) ≈um oh I mean u:h:≈ ",
"((m: r h half open palm facing down @uprperi)) ", "the US reaches it's um ",
"budget deficit, >its maximum budget deficit< °what 's° (.) °what 's that called again?° ",
"((m: r h silent snapping of fingers @rperi)) ", "((m: r h open palm facing in @erperi)) ",
"°governmental° ", "((m: r h open palm facing up + away @erperi)) ",
"tt >I don't know so there 's a government shutdown< ", "the [fiscal cliff] ",
"[a:nd the !fiscal!] yeah °ye[ah]° (.) and u:h and so as a result all new positions are cut ",
"((m: r h points forward w: index and thumb @upct)) ", "((m: r h half open palm facing up index + thumb extended @erperi)) "
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-60L))
df2 <- structure(list(A = c(2.401, 2.401, 2.401, 2.401, 2.401, 2.401,
2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401,
2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401,
2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401,
2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401,
2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401,
2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401,
2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401,
2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401,
2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401,
2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401,
2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 2.401, 4.16,
4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16,
4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16,
4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16,
4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.16, 4.152,
4.154, 4.154, 4.154, 4.154, 4.154, 4.154, 4.154, 4.154, 4.154,
4.154, 4.154, 4.154, 4.154, 4.154, 4.154, 4.154, 4.154, 4.154,
4.154, 4.154, 4.154, 4.154, 4.154, 4.154, 4.154, 4.154, 4.154,
4.154, 4.154, 4.154, 4.154, 4.154, 4.154, 4.154, 4.154), Starttime_ms = c(309003,
309014, 309015, 309019, 309032, 309036, 309047, 309049, 309053,
309065, 309069, 309080, 309082, 309086, 309099, 309103, 309114,
309115, 309119, 309132, 309136, 309147, 309149, 309153, 309165,
309169, 309180, 309182, 309186, 309199, 309203, 309214, 309215,
309219, 309232, 309236, 309247, 309249, 309265, 309280, 309282,
309299, 309314, 309315, 309332, 309347, 309349, 309365, 309380,
309382, 309399, 309414, 309415, 309432, 309447, 309449, 309465,
309480, 309482, 309499, 309514, 309515, 309532, 309547, 309549,
309565, 309580, 309582, 309599, 309614, 309615, 309632, 309647,
309649, 309665, 309680, 309682, 309699, 309714, 309715, 309732,
309747, 309749, 309765, 309780, 309782, 309799, 309814, 309815,
309832, 309847, 309849, 309865, 309880, 309882, 309899, 309914,
309915, 309932, 309947, 309949, 309965, 309980, 309982, 369502,
369505, 369517, 369519, 369522, 369535, 369538, 369551, 369552,
369555, 369569, 369572, 369584, 369585, 369588, 369602, 369605,
369617, 369619, 369622, 369635, 369638, 369650, 369651, 369652,
369655, 369669, 369672, 369683, 369684, 369685, 369688, 369702,
369705, 369716, 369717, 369719, 369722, 369735, 369738, 369751,
369752, 369755, 369769, 369772, 369784, 369785, 369788, 369802,
369805, 369817, 369819, 369822, 369835, 369838, 369850, 369851,
369852, 369855, 369869, 369872, 369883, 369884, 369885, 369888,
369902, 369905, 369917, 369919, 369922, 369935, 369938, 369951,
369952, 369955, 369969, 369972, 369984, 369985), Endtime_ms = c(309014,
309015, 309019, 309032, 309036, 309047, 309049, 309053, 309065,
309069, 309080, 309082, 309086, 309099, 309103, 309114, 309115,
309119, 309132, 309136, 309147, 309149, 309153, 309165, 309169,
309180, 309182, 309186, 309199, 309203, 309214, 309215, 309219,
309232, 309236, 309247, 309249, 309265, 309280, 309282, 309299,
309314, 309315, 309332, 309347, 309349, 309365, 309380, 309382,
309399, 309414, 309415, 309432, 309447, 309449, 309465, 309480,
309482, 309499, 309514, 309515, 309532, 309547, 309549, 309565,
309580, 309582, 309599, 309614, 309615, 309632, 309647, 309649,
309665, 309680, 309682, 309699, 309714, 309715, 309732, 309747,
309749, 309765, 309780, 309782, 309799, 309814, 309815, 309832,
309847, 309849, 309865, 309880, 309882, 309899, 309914, 309915,
309932, 309947, 309949, 309965, 309980, 309982, 309999, 369505,
369517, 369519, 369522, 369535, 369538, 369551, 369552, 369555,
369569, 369572, 369584, 369585, 369588, 369602, 369605, 369617,
369619, 369622, 369635, 369638, 369650, 369651, 369652, 369655,
369669, 369672, 369683, 369684, 369685, 369688, 369702, 369705,
369716, 369717, 369719, 369722, 369735, 369738, 369751, 369752,
369755, 369769, 369772, 369784, 369785, 369788, 369802, 369805,
369817, 369819, 369822, 369835, 369838, 369850, 369851, 369852,
369855, 369869, 369872, 369883, 369884, 369885, 369888, 369902,
369905, 369917, 369919, 369922, 369935, 369938, 369951, 369952,
369955, 369969, 369972, 369984, 369985, 369988), File = c("F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01", "F01",
"F01", "F01", "F01", "F01", "F16", "F16", "F16", "F16", "F16",
"F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16",
"F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16",
"F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16",
"F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16",
"F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16",
"F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16",
"F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16",
"F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16", "F16",
"F16", "F16")), row.names = c(NA, -183L), class = "data.frame")
答: 暂无答案
评论
by Columns by which to join the two tables. If provided, this must be two columns: start of interval, then end of interval