The following is the sample data set drawn above:
> dput(d3)
structure(list(y = c(344L, 347L, 340L, 716L, 736L, 1061L, 911L,
299L, 296L, 294L, 295L, 292L, 290L, 291L, 591L, 592L, 199L, 198L,
196L, 192L, 270L, 271L, 272L, 275L, 276L, 277L, 278L, 279L, 524L,
523L, 442L, 441L, 446L, 100L, 106L, 905L, 33L, 31L, 30L, 37L,
642L, 438L, 339L, 338L, 334L, 337L, 336L, 333L, 332L, 744L, 745L,
857L, 6L, 98L, 844L, 95L, 557L, 556L, 552L, 238L, 235L, 236L,
231L, 1050L, 1053L, 143L, 140L, 141L, 613L, 617L, 148L, 149L,
951L, 941L, 689L, 683L, 132L, 134L, 139L, 490L, 26L, 27L, 22L,
28L, 379L, 378L, 371L, 370L, 373L, 374L, 705L, 702L, 392L, 83L,
8 4L, 85L, 797L, 790L, 7L, 584L, 245L, 246L, 240L, 924L, 926L,
511L, 512L, 515L, 452L, 453L, 456L, 457L, 179L, 178L, 176L, 174L,
170L, 182L, 183L, 181L, 187L, 184L, 185L, 886L, 189L, 10L, 15L,
14L, 17L, 16L, 19L, 864L, 884L, 881L, 950L, 323L, 321L, 326L,
327L, 201L, 200L, 202L, 208L, 77L, 76L, 75L, 72L, 71L, 70L, 78L,
2L, 1048L, 664L, 662L, 699L, 542L, 547L, 68L, 869L, 123L, 124L,
765L, 1010L, 920L, 923L, 776L, 499L, 319L, 313L, 312L, 314L,
921L, 832L, 3L, 725L, 366L, 364L, 365L, 363L, 360L, 381L, 382L,
383L, 384L, 387L, 389L, 788L, 579L, 576L, 259L, 64L, 65L, 66L,
67L, 252L, 250L, 251L, 257L, 254L, 255L, 603L, 508L, 509L, 506L,
507L, 502L, 503L, 500L, 468L, 463L, 164L, 165L, 166L, 162L, 163L,
1102L, 9L, 893L, 894L, 357L, 355L, 353L, 351L, 350L, 807L, 358L,
214L, 215L, 218L, 1033L, 1074L, 1070L, 1003L, 281L, 280L, 283L,
282L, 285L, 284L, 287L, 286L, 678L, 679L, 675L, 263L, 261L, 264L,
1031L, 269L, 58L, 57 L, 51L, 50L, 53L, 52L, 537L, 533L, 532L,
531L, 539L, 981L, 986L, 985L, 953L, 301L, 824L, 826L, 820L, 1038L,
1039L, 1046L, 569L, 737L, 560L, 562L, 564L, 229L, 227L, 226L,
222L, 221L, 220L, 1001L, 1024L, 391L, 723L, 728L, 151L, 158L,
635L, 48L, 49L, 45L, 43L, 40L, 5L, 484L, 483L, 481L, 473L, 471L,
375.671887635388, 501.150181751124, 1632.64480524179, 320.220059 >935.065925414262, 528.919542438531, 261.151001000102, 296.697708329904,
493.42302269819, 627.780232158787, 493.42302269819, 177.583807543134,
72.7078418069536, 566. , 394.237135327563, 394.237135327563, 437.874912052593,
511.931469081634, 593.138212655188, 499.694916209964, 987.649912212124,
681.48357294428, 861.863386887195, 368.418124724488, 23 6.465797054011,
368.946054867084, 84.5644646808382, 351.560834895982, 373.060292380781,
333.487546395183, 343.956719824158, 149.27381942208, 421.818147772037,
531.856634917506, 616.120468354171, 20.6888972224936, 464.585778027563,
68.1535379191005, 865.333184046004, 501.894506744091, 359.421135214661,
144.659764185851, 348.371459003868, 344.286421591311, 431.056246654705,
445.387821613564, 1098.06540398953, 338.097004919986, 103.346419349034, 348.371459003868, 344.286421591311, 431.056246654705,
445.387821613564, 1098.06540398953, 338.097004919986, 103.346419349034, 88.2361894833218, 259. 252.146941101945, 389.937432751327, 338.09700 4919986, 451.760711631279,
812.343817687462, 259.944624253393, 265.870628628874, 24.2060322743025,
97.5630276432801, 71.5164956426049, 63.6633694922466, 73.0889909848329,
812.343817687462, 264. 138.613227738621,
430.711634705192, 464.743286282379, 778.874106395508, 1632.64480524179,
582.561160820872, 849.726543551087, 304.087902126991, 418.531564881009,
862.
732.372816752337, 426.856562850548, 271.258100351862, 313.847016657358,
1298.52330195319, 346.148403288736, 492.977331902279, 370.083871916793,
389.012696704257, 401.482731769436, 370.0838102. />503.304967310127, 967.055102889789 , 495.809837197111, 814.195055402879,
581.012263017256, 566.889975368825, 708.956511139747, 98.631335954673,
104.108593469476, 102.371427215996, 60.5764116719274, 814.195055402879,
, 74.727006266432,
708.962458123489, 664.596397815476, 85.7400117854313, 974.60025714224,
74.727006266432, 97.5630276432801, 358.209664224869, 612.020236159809,
708.962458123489, 664. ,
469.938245675386, 882.984214454269, 639.029128677423, 32.7204383490066,
894.282873043937, 631.613900497221, 631.613900497221, 469.938245675386,
316.61466421411, 273.374. br />492.977331902279, 661.560016 581062, 232.042178972458, 159.735908778631,
404.331646707662, 404.331646707662, 343.956719824158, 132.5401492497,
803.203868935649, 536.233331817024, 582.432298144919, 159.735908778631, 214. 346.942291151142, 346.942291151142,
1132.54398137967, 92.0708768788675, 674.493208966483, 671.12148984204,
459.026795332829, 455.04549028781, 660.33733340859, 956.138
784.158
289.336271404564, 289.33 6271404564, 248.954088630692, 248.954088630692,
357.396135881107, 318.679166035926, 215.463571984583, 318.679166035926,
652.199052646016, 439.789286568842, 94.9177745635627, 248.954088630692, 602.545598216988, 787.05450936268,
1217.48806744917, 3951.97397981284, 1271.19179175426, 1271.19179175426,
1086.7331143726, 288.657151872425, 641.880175939599, 513.448663631568 3636.49647739135,
2283.84282466004, 227.255824930042, 171.451878242148, 171.451878242148,
77.5562969955613, 473.285380419838, 515.823314677668, 560.62136401321,
2283.84282466004, 227.255824930042, 171.451878242148, 171.451878242148,
77.5562969955613, 473.285380419838, 515.823314677668, 560.62136401321,
234.739496859824 , 82.4150762804732, 193.006007370882, 385.525743098602,
517.792954848677, 475.212437582284, 729.636269127372, 799.573084076505,
1085.10956517537, 254.782666913692, 1085.13362066613081), med2 = c(5.9206-1014506318247) -10, 179.928092448528, 301.156872476219,
778.874106395508, 41.6982282937699, 5.90034687775187e-10, 5.92081050854176e-10,
5.92081050854176e-10, 5.91171556152403e-10, 5.92081050854176e-10,
12.5341747219229, 6.12089934293181e-10, 6.11180439591408e-10,
6.12999428994954e-10, 6.13908923696727e-10, 5.89352566748857e-10,
5.91171556152403 e-10, 5.91171556152403e-10, 5.91171556152403e-10,
5.9026206145063e-10, 5.9026206145063e-10, 5.90716808801517e-10,
5.92081050854176e-10, 6.09361450187862e-10, 6.10270944889635e- 10,
5.6979843066074e-10, 5.62977220397443e-10, 5.6206772569567e-10,
5.92990545555949e-10, 5.939000402577 22e-10, 148.37447303732,
5.92081050854176e-10, 5.92990545555949e-10, 5.92990545555949e-10,
5.93900040257722e-10, 336.779474319648, 5.71162672713399e-10,
5.91171556152403e-10, 5.91171556152403e-10, 5.90489435126074e-10,
5.90489435126074e-10, 5.9026206145063e-10, 5.90489435126074e-10,
5.91171556152403e-10, 1256.13764195129, 1201.66195244627, 143.820378219854,
5.92081050854176e-10, 6.15727913100272e-10, 6.14818418398499e-10,
6.15727913100272e-10, 6.11180439591408e-10, 6.12089934293181e-10,
6.11180439591408e-10, 6.12999428994954e-10, 1128.5849841858,
830.330465171175, 5.92990545555949e-10, 5.93900040257722e-10,
5.93900040257722e-10, 262.855361520932, 193.006007370882, 5.93900040257722e-10,
5.92081050854176e-10, 85.027459714511, 271.512533289177, 4.40771726481739,
116.280381261191, 5.95719029661268e-10, 5.92990545555949e-10,
5.92990545555949e-10, 6.18001649854705e-10, 5.93445292906836e-10,
5.94809534959495e-10, 5.94809534959495e-10, 5.93445292906836e-10,
5.89352566748857e-10, 5.90716808801517e-10, 5.87533577345312e-10,
5.88443072047085e-10, 5.89352566748857e-10, 5.89807314099744e-10,
14.696963239845, 70.6343870644591, 6.11635186942294e-10, 5.92990545555949e-10,
5.92990545555949e-10, 5.92990545555949e-10, 452.386758287036 ,
166.535720816878, 5.91171556152403e-10, 453.15187309193, 6.10725692240521e-10,
6.04359229328111e-10, 6.12089934293181e-10, 199.714331200633,
456.915214125292, 5.62295099371113e-10, 6.28006091574207e-10 ,
6.08451955486089e-10, 5.61158230993897e-10, 5.63886715099216e-10,
5.69343683309853e-10, 5.69343683309853e-10, 5.9867488744203e-10,
5.9867488744203e-10, 6.00266503170133e -10, 5.9935700846836e-10,
5.92081050854176e-10, 6.13908923696727e-10, 6.12999428994954e-10,
6.00266503170133e-10, 6.13908923696727e-10, 6.12999428994954e-10,
6.1 2999428994954e-10, 814.195055402879, 6.12089934293181e-10,
5.90716808801517e-10, 5.92990545555949e-10, 5.93900040257722e-10,
5.94809534959495e-10, 5.92990545555949e-10, 5.94582161284052e-10, < br />175.007987968935, 337.819321648658, 292.942892808184, 180.602980309193,
5.88897819397971e-10, 5.91398929827847e-10, 5.88443072047085e-10,
5.89807314099744e-10, 6.11180439591408e-10, 6.13908923696727e-10,
br />6.12544681644067e-10, 6.10270944889635e-10, 5.94809534959495e-10,
5.92990545555949e-10, 5.92990545555949e-10, 5.92990545555949e-10,
5.92990545555949e-10, 5.92990545555949e-10 , 5.92535798205063e-10,
5.9026206145063e-10, 425.036556400271, 35.98546337373, 2.86016765982458,
46.9208715756442, 6.09361450187862e-10, 6.14818418398499e-10,
5.92990545555949e-10, 652.507077085912154e -10,
5.95719029661268e-10, 167.662601125897, 375.261535909629, 469.938245675386,
430.711634705192, 128.777045136448, 6.30279828328639e-10 , 5.91171556152403e-10,
5.89807314099744e-10, 5.89807314099744e-10, 5.94809534959495e-10,
464.743286282379, 32.3722423912727, 5.9026206145063e-10, 3.88751825289819,
5.87988324696198e-10, 5.9026206145063 e-10, 5.9026206145063e-10,
5.88897819397971e-10, 5.9026206145063e-10, 5.88443072047085e-10,
5.86169335292652e-10, 5.86169335292652e-10, 5.88443072047085e-10,
5.89352566748857e-10, 6.07542460784316e-10, 473.285380419838,
95.5639665826079, 563.485296227425, 5.91171556152403e-10, 5.94809534959495e-10,
5.91171556152403e-10, 5.91171556152403e-10, 5.94809534959495e-10,
5.91171556152403e-10, 6.02540239924565e-10, 5.9026206145063e-10,
5.9026206145063e-10, 5.89352566748857e-10, 5.91171556152403e-10,
393.679367001997, 5.66615199204534e-10, 5.66615199204534 e-10,
5.6843418860808e-10, 5.66615199204534e-10, 5.66615199204534e-10,
5.6843418860808e-10, 6.30279828328639e-10, 5.64796209800988e-10,
5.6206772569567e-10 , 5.902 6206145063e-10, 5.92081050854176e-10,
5.9026206145063e-10, 5.9935700846836e-10, 5.9935700846836e-10,
1026.02188411319, 5.92081050854176e-10, 617.628362503441, 20.2162425363044,
5.88897819397971e- 10, 5.89352566748857e-10, 5.9026206145063e-10,
5.9026206145063e-10, 5.9026206145063e-10, 458.424240700748, 5.89352566748857e-10,
6.12089934293181e-10, 6.12089934293181e-10, 6.12999428994954e- 10,
540.874405445984, 33.2823647426485, 306.504635592015, 149.27381942208,
5.91171556152403e-10, 5.9026206145063e-10, 5.89807314099744e-10,
5.9026206145063e-10, 5.9026206145063e-10, 5.89352566748857e- 10,
5.92990545555949e-10, 5.92990545555949e-10, 119.618497227977,
236.465797054011, 290.969520110033, 5.9026206145063e-10, 5.90489435126074e-10,
5.9026206145063e-10, 92.0708768788675, 5.89352566748857e- 10,
5.93900040257722e-10, 5.93900040257722e-10, 5.93900040257722e-10,
5.92081050854176e-10, 5.93445292906836e-10, 5.92990545555949e-10 ,
6.08224581810646e-10, 6.10043571214192e-10, 6.08451955486089e-10,
6.08451955486089e-10, 6.0572347138077e-10, 1993.46125096711,
891.18648034266, 1.49003914297919, 71.5164956426049, 5.9026206145063e-10 ,
232.042178972458, 440.893230387429, 132.5401492497, 412.005752342262,
1.4471257259197, 475.212437582284, 430.225519702263, 32.8873311707098,
3951.97397981284, 2535.66125304385, 1713.09859035141, 6.148417, e-10, 6.12999428994954e-10,
6.14818418398499e-10, 6.13908923696727e-10, 336.473072699556,
16.377896678119, 6.2118488131091e-10, 38.3288998547109, 722.521996474829,
5.91171556152403e-10, 5.9162630350329 e-10, 86.1396602370546,
5.92081050854176e-10, 5.92081050854176e-10, 5.93900040257722e-10,
5.92990545555949e-10, 5.93900040257722e-10, 5.91171556152403e-10,
5.64796209800988e -10, 5.65705704502761e-10, 5.67069946555421e-10,
6.33008312433958e-10, 5.6843418860808 e-10, 6.32098817732185e-10
)), .Names = c("y", "med1", "med2"), class = "data.frame", row.names = c(NA, < br />-302L))
library(ggplot2)
library(data.table)
library(cowplot)
range <- range(d3[-1 ])
dt1 <- data.table(start = floor(seq(range[1], range[2]+1, 1)))[,end := start + 1]
setkey( dt1, start, end)
dt2 <- data.table(start = d3$med2, end = d3$med1)
dt <- foverlaps(dt2, dt1)[,.N,by=" start"]
p1 <- ggplot(d3, aes(x=med1,xend=med2,y=y,yend=y)) + geom_segment()
p2 <- ggplot( dt, aes(x=start, y=N)) + geom_line()
plot_grid(
p1 + xlim(0,4500),
p2 + xlim(0,4500), < br /> ncol = 1, align = "h"
)
I can see a series of time ranges below (note that the y-axis does not matter). I want to “smooth” these data so that along the x The axis is given any time, I know how many segments span that moment. I found a few on how to calculate Posts on moving averages in R; however, they are all based on time series data. I am looking for suggestions on how to aggregate my data, the format of which is “start” and “stop” in the form of “at time (x), there is y events span that time”.
< /p>
The following is the sample data set drawn above:
> dput(d3)
structure(list(y = c(344L, 347L, 340L, 716L, 736L, 1061L, 911L,
299L, 296L, 294L, 295L, 292L, 290L, 291L, 591L, 592L, 199L, 198L,
196L, 192L, 270L, 271L, 272L, 275L, 276L, 277L, 278L, 279L, 524L,
523L, 442L, 441L, 446L, 100L, 106L, 905L, 33L, 31L, 30L, 37L,
642L, 438L, 339L, 338L, 334L, 337L, 336L, 333L, 332L, 744L, 745L,
857L, 6L, 98L, 844L, 95L, 557L, 556L, 552L, 238L, 235L, 236L,
231L, 1050L, 1053L, 143L, 140L, 141L, 613L, 617L, 148L, 149L,
951L, 941L, 689L, 683L, 132L, 134L, 139L, 490L, 26L, 27L, 22L,
28L, 379L, 378L, 371L, 370L, 373L, 374L, 705L, 702L, 392L, 83L,
84L, 85L, 797L, 790L, 7L, 584L, 245L, 246L, 240L, 924L, 926L,
511L, 512L, 515L, 452L, 453L, 456L, 457L, 179L, 178L, 176L, 174L,
170L, 182L, 183L, 181L, 187L, 184L, 185L, 886L, 189L, 10L, 15L,
14L, 17L, 16L, 19L, 864L, 884L, 881L, 950L, 323L, 321L, 326L,
327L, 201L, 200L, 202L, 208L, 77L, 76L, 75L, 72L, 71L, 70L, 78L,
2L, 1048L, 664L, 662L, 699L, 542L, 547L, 68L, 869L, 123L, 124L,
765L, 1010L, 920L, 923L, 776L, 499L, 319L, 313L, 312L, 314L,
921L, 832L, 3L, 725L, 366L, 364L, 365L, 363L, 360L, 381L, 382L,
383L, 384L, 387L, 389L, 788L, 579L, 576L, 259L, 64L, 65L, 66L,
67L, 252L, 250L, 251L, 257L, 254L, 255L, 603L, 508L, 509L, 506L,
507L, 502L, 503L, 500L, 468L, 463L, 164L, 165L, 166L, 162L, 163L,
1102L, 9L, 893L, 894L, 357L, 355L, 353L, 351L, 350L, 807L, 358L,
214L, 215L, 218L, 1033L, 1074L, 1070L, 1003L, 281L, 280L, 283L,
282L, 285L, 284L, 287L, 286L, 678L, 679L, 675L, 263L, 261L, 264L,
1031L, 269L, 58L, 57L, 51L, 50L, 53L, 52L, 537L, 533L, 532L,
531L, 539L, 981L, 986L, 985L, 953L, 301L, 824L, 826L, 820L, 1 038L,
1039L, 1046L, 569L, 737L, 560L, 562L, 564L, 229L, 227L, 226L,
222L, 221L, 220L, 1001L, 1024L, 391L, 723L, 728L, 151L, 158L,
635L, 48L, 49L, 45L, 43L, 40L, 5L, 484L, 483L, 481L, 473L, 471L,
479L), med1 = c(368.946054867084, 291.897692486097, 686.551291017994,
375.671887635388 , 501.150181751425, 1632.64480524179, 320.220059124658,
935.065925414262, 528.919542438531, 261.151001000102, 296.697708329904,
464.585778027563, 394.237135327563, 394.237135327563, 437.874912052593,
511.931469081634, 593.138212655188, 499.694916209964, 482.706249756357,
, 373.060292380781,
333.4875 46395183, 343.956719824158, 149.27381942208, 421.818147772037,
421.818147772037, 472.218398688553, 504.080212384862, 476.8894460605,
860.119004262127, 452.386758287036, 687.246054743733, 377.062322047126,
276.156428704474, 88.2361894833218, 259.763127895686, 36.6402501681159,
1033.30059558483, 179.704099736262, 286.793504544989, 230.973431897317,
24.2060322743025,
97.5630276432801, 71.5164956426049, 63.6633694922466, 73.0889909848329,
76.7660834978547, 692.220546028846, 294.602836904093, 67.1432835867822,
389.012696704257, 401.482731769436, 370.083871916793, 12.5341747219229,
619.71859994423, 967.055102889789, 1108.94429180952, 831.1863402503. 708.956511139747, 98.6313359 54673,
104.108593469476, 102.371427215996, 60.5764116719274, 63.6985066343227,
63.6985066343227, 70.127908932847, 80.9301606341051, 430.225519702263,
74.727006266432, 97.5630276432801, 358.209664224869, 612.020236159809,
899.681910031094, 458.085887228637, 587.412810034177, 1132.54398137967,
333.244273558609, 866.439023248492, 866.439023248469, 492,438,454,386,846. />894.282873043937, 631.613900497221, 631.613900497221, 469.938245675386,
316.61466421411, 273.374729548883, 296.944858892382, 296.944858892382, 631.613900497221, 631.613900497221, 469.938245675386,
316.61466421411, 273. 404.331646707662, 404.331646707662, 343.956719824158, 132. 5401492497,
803.203868935649, 536.233331817024, 582.432298144919, 458.411027323615,
190.174640246333, 433.200958781613, 431.395485521417, 306.504635592015,
373.881627748, - />378.391904588357, 469.975759957832, 606.309875063964, 935.158184896916,
576.507044635476, 336.473072699556, 466.08988453481, 466.08988453481, 469.975759957832, 606.309875063964, 935.158184896916,
576.507044635476, 336.473072699556, 466.08988453481, 466.08988453481, 469.975759957832, 289271336. 357.396135881107, 318.679166035926, 215.463571984583, 318.679166035926,
652.199052646016, 439.789286568842, 94.9177745635627, 94.9177745635627,
652.199052646016, 439.789286568842, 94.9177745635627, 94.9177745635627, 234.739496859824, 208.683665151238, 224.967707240973,
1086.7331143726, 288.657151872425, 641.880175939599, 513.448663631554,
761.79612221564, 301.1568. />77.5562969955613, 473.285380419838, 515.823314677668, 560.62136401321,
470.072223539501, 1086.7331143726, 502.951389943578, 1087.00389974226, 473.285380419838, 762. 517.792954848677, 475.212437582284, 729.636269 127372, 799.573084076505,
1085.10956517537, 254.782666913692, 1085.13366613081), med2 = c(5.9094418247696e-10,
5.9026206145063e-10, 5.9026206145063e-10, 179.928092448528, 301.156872476219,
, 4778.8741063955081.6982937 5.90034687775187e-10, 5.92081050854176e-10,
5.92081050854176e-10, 5.91171556152403e-10, 5.92081050854176e-10,
5.9026206145063e-10, 5.92081050854176e-10, 72.7078418069536,
12.5341747219229 , 6.12089934293181e-10, 6.11180439591408e-10,
6.12999428994954e-10, 6.13908923696727e-10, 5.89352566748857e-10,
5.91171556152403e-10, 5.91171556152403e-10, 5.91171556152403e-10, < br />5.9026206145063e-10, 5.9026206145063e-10, 5.90716808801517e-10,
5.92081050854176e-10, 6.09361450187862e-10, 6.10270944889635e-10,
5.6979843066074e-10, 5.62977220397443e-10 , 5.6206772569567e-10,
5.92990545555949e-10, 5.93900040257722e-10, 148.37447303732,
5.92081050854176e-10, 5.92990545555949e-10, 5.92990545555949e-10,
5.939 00040257722e-10, 336.779474319648, 5.71162672713399e-10,
5.91171556152403e-10, 5.91171556152403e-10, 5.90489435126074e-10,
5.90489435126074e-10, 5.9026206145063e-10, 5.90489435126074e-10, < br />5.91171556152403e-10, 1256.13764195129, 1201.66195244627, 143.820378219854,
5.91398929827847e-10, 5.92081050854176e-10, 18.0578118741103,
5.92081050854176e-10, 6.15727913100272e-10, 6.14818418398499e-10,
br />6.15727913100272e-10, 6.11180439591408e-10, 6.12089934293181e-10,
6.11180439591408e-10, 6.12999428994954e-10, 1128.5849841858,
830.330465171175, 5.92990545555949e-10, 5.93900040257722e-10,
5.93900040257722e-10, 262.855361520932, 193.006007370882, 5.93900040257722e-10,
5.92081050854176e-10, 85.027459714511, 271.512533289177, 4.40771726481739,
116.280381261191, 5.95719029661268e-10, 5.92990555555 br />5.92990545555949e-10, 6.18001649854705e-10, 5.93445292906836e-10,
5.94809534959495e-10, 5.94809534959495e-10, 5.934452929068 36e-10,
5.89352566748857e-10, 5.90716808801517e-10, 5.87533577345312e-10,
5.88443072047085e-10, 5.89352566748857e-10, 5.89807314099744e-10,
14.696963239845, 70.6343870644591, 6.11635186942294e-10, 5.92990545555949e-10,
5.92990545555949e-10, 5.92990545555949e-10, 452.386758287036,
166.535720816878, 5.91171556152403e-10, 453.15187309193, 6.10725692240521e-10,
6.04359229328111e -10, 6.12089934293181e-10, 199.714331200633,
456.915214125292, 5.62295099371113e-10, 6.28006091574207e-10,
6.08451955486089e-10, 5.61158230993897e-10, 5.63886715099216e-10,
5.69343683309853 e-10, 5.69343683309853e-10, 5.9867488744203e-10,
5.9867488744203e-10, 6.00266503170133e-10, 5.9935700846836e-10,
5.92081050854176e-10, 6.13908923696727e-10, 6.12999428994954e- 10,
6.00266503170133e-10, 6.13908923696727e-10, 6.12999428994954e-10,
6.12999428994954e-10, 814.195055402879, 6.12089934293181e-10,
5.90716808801517e-10, 5.92990545555949e-10 , 5.93900040257722e-10,
5.94809534959495e-10, 5.92990545555949e-10, 5.94582161284052e-10,
175.007987968935, 337.819321648658, 292.942892808184, 180.602980309193,
5.88897819397971e-10, 5.91398929827847e-10, 5.88443072047085e-10,
5.89807314099744e-10, 6.11180439591408e-10, 6.13908923696727e-10,
6.12544681644067e-10, 6.10270944889635e-10, 5.94809534959495e-10,
5.92990545555949e- 10, 5.92990545555949e-10, 5.92990545555949e-10,
5.92990545555949e-10, 5.92990545555949e-10, 5.92535798205063e-10,
5.9026206145063e-10, 425.036556400271, 35.98546337373, 2.86016765982458,
46.9208715756442, 6. , 6.30279828328639e-10, 5.91171556152403e-10,
5.89807314099744e-10, 5.89807314099744e-10, 5.94809534959495e-10,
464.74 3286282379, 32.3722423912727, 5.9026206145063e-10, 3.88751825289819,
5.87988324696198e-10, 5.9026206145063e-10, 5.9026206145063e-10,
5.88897819397971e-10, 5.9026206145063e-10, 5.88443072047085e-10, < br />5.86169335292652e-10, 5.86169335292652e-10, 5.88443072047085e-10,
5.89352566748857e-10, 6.07542460784316e-10, 473.285380419838,
95.5639665826079, 563.485296227425, 5.91171556152403e-10, 5.94809534959495e- 10,
5.91171556152403e-10, 5.91171556152403e-10, 5.94809534959495e-10,
5.91171556152403e-10, 6.02540239924565e-10, 5.9026206145063e-10,
5.9026206145063e-10, 5.89352566748857 e-10, 5.91171556152403e-10,
393.679367001997, 5.66615199204534e-10, 5.66615199204534e-10,
5.6843418860808e-10, 5.66615199204534e-10, 5.66615199204534e-10,
5.6843418860808e -10, 6.30279828328639e-10, 5.64796209800988e-10,
5.6206772569567e-10, 5.9026206145063e-10, 5.92081050854176e-10,
5.9026206145063e-10, 5.9935700846836e-10, 5.9935700846836e-10 , < br />1026.02188411319, 5.92081050854176e-10, 617.628362503441, 20.2162425363044,
5.88897819397971e-10, 5.89352566748857e-10, 5.9026206145063e-10,
5.9026206145063e-10, 5.9026 5.206145063e-10, 458.424667488700748, e-10,
6.12089934293181e-10, 6.12089934293181e-10, 6.12999428994954e-10,
540.874405445984, 33.2823647426485, 306.504635592015, 149.27381942208,
5.91171556152403e-10, 5.9026206145063e-10, 5.89807314099744 e-10,
5.9026206145063e-10, 5.9026206145063e-10, 5.89352566748857e-10,
5.92990545555949e-10, 5.92990545555949e-10, 119.618497227977,
236.465797054011, 290.969520110033, 5.9026206145063e- 10, 5.90489435126074e-10,
5.9026206145063e-10, 92.0708768788675, 5.89352566748857e-10,
5.93900040257722e-10, 5.93900040257722e-10, 5.93900040257722e-10,
5.92081050854176e-10 , 5.93445292906836e-10, 5.92990545555949e-10,
6.08224581810646e-10, 6.10043571214192e-10, 6.08451955486089e-10,
6.08451955486089e-10, 6.0572 347138077e-10, 1993.46125096711,
891.18648034266, 1.49003914297919, 71.5164956426049, 5.9026206145063e-10,
232.042178972458, 440.893230387429, 132.5401492497, 412.005752342262,
1.4471257259197, 475.212437582284, 430.225519702263, 32.8873311707098,
3951.97397981284, 2535.66125304385, 1713.09859035141, 6.14818418398499e-10,
6.1345417634584e-10, 6.1345417634584e-10, 6.12999428994954e-10,
6.14818418398499e-10, 6.13908923696727e-10, 336.473072699556,
16.377896678119, 6.2118488131091e-10, 38.3288998547109, 722.521996474829,
5.91171556152403e-10, 5.9162630350329e-10, 86.1396602370546,
5.92081050854176e-10, 5.92081050854176e-10, 5.93900040257722e-10,
5.92990545555949e-10, 5.93900040257722e-10, 5.91171556152403e-10,
5.64796209800988e-10, 5.65705704502761e-10, 5.67069946555421e-10,
6.33008312433958e-10, 5.6843418860808e-10, 6.32098817732185e-10
)), .Names = c("y", "med1", "med2"), class = "data.frame", row.names = c(NA,
-302L))
也许你可以建立一些东西:
library(ggplot2)
library(data.table)
library(cowplot)
range <- range(d3[-1])
dt1 <- data.table(start = floor(seq(range[1], range[2]+1, 1)))[,end := start + 1]
setkey(dt1, start, end)
dt2 <- data.table(start = d3$med2, end = d3$med1)
dt <- foverlaps(dt2, dt1)[,.N,by="start"]
p1 <- ggplot(d3, aes(x=med1,xend=med2,y=y,yend=y)) + geom_segment()
p2 <- ggplot(dt, aes(x=start, y=N)) + geom_line()
plot_grid(
p1 + xlim(0,4500),
p2 + xlim(0,4500),
ncol = 1, align = "h"
)