 segment.start, segment.end)
setkey(positions, pos, pos2)

As a point of explanation, foverlaps requires that both frames have two fields, with the premise of the function being an overlap in the range of one frame with the overlap of the other frame. As much as one might argue that having a single column option in this overlap-check might be useful, the addition of a second column (pos2 in this case) is trivial and enables exactly the same functionality without changing data.table code.
Edit: updated to include "by chr" logic.
Edit 2: inverted, resulting in positions as the primary:
foverlaps(positions, segments) [
   ,.(count = sum(!is.na(segment.start))), by =.(chr, pos, pos2) ][
   , pos2 := NULL ]
#     chr     pos count
#  1:   1  750000     1
#  2:   1  806000     1
#  3:   1  862000     1
#  4:   1  918000     1
#  5:   1  974000     1
#  6:   1 1030000     0
#  7:   1 1086000     0
#  8:   1 1142000     0
#  9:   1 1198000     0
# 10:   1 1254000     0
# 11:   1 1310000     0
# 12:   1 1366000     0
# 13:   1 1422000     0
# 14:   1 1478000     0
# 15:   1 1534000     0
# 16:   1 1590000     0
# 17:   1 1646000     0
# 18:   1 1702000     0
# 19:   1 1758000     1
# 20:   1 1814000     1
# 21:   1 1870000     1
# 22:   1 1926000     1
# 23:   1 1982000     1
#     chr     pos count

 Q:

QoS or more bandwidth?

Being in SP field I sometimes hear folks say "we do not need QoS, just let's make sure we have enough bandwidth".
This has always been bothering me, because currently we have a network without any QoS
segment.start, segment.end) 
 setkey(positions, pos, pos2) 

 As a point of explanation, foverlaps requires that both frames get two field, with the premise of the function being an overlap in the range of one inning with the overlap of the other skeletal system. equally much as one might argue that having a single column option in this overlap - check might be utilitarian, the addition of a second column (pos2 in this case) is trivial and enables precisely the same functionality without changing data.table code. 
 Edit: updated to include " by chr " logic. 
 Edit 2: inverted, result in positions as the primary: 
 foverlaps(positions, segments) [ 
   , .(count = sum(!is.na(segment.start) )), by = .(chr, pos, pos2) ] [ 
   , pos2: = nothing ] 
 #      chr      pos count 
 #   1:    1   750000      1 
 #   2:    1   806000      1 
 #   3:    1   862000      1 
 #   4:    1   918000      1 
 #   5:    1   974000      1 
 #   6:    1 1030000      0 
 #   7:    1 1086000      0 
 #   8:    1 1142000      0 
 #   9:    1 1198000      0 
 # 10:    1 1254000      0 
 # 11:    1 1310000      0 
 # 12:    1 1366000      0 
 # 13:    1 1422000      0 
 # 14:    1 1478000      0 
 # 15:    1 1534000      0 
 # 16:    1 1590000      0 
 # 17:    1 1646000      0 
 # 18:    1 1702000      0 
 # 19:    1 1758000      1 
 # 20:    1 1814000      1 
 # 21:    1 1870000      1 
 # 22:    1 1926000      1 
 # 23:    1 1982000      1 
 #      chr      pos count 

  Q: 

 QoS or more bandwidth? 

 Being in SP plain I sometimes hear folk say " we do not need QoS, just let's make certain we have enough bandwidth ". 
 This has always been bothering me, because currently we accept a network without any QoS
 sehment.start, segment.end)
setyey(positions, pos, pos2)

As a poiht of exolanation, foverlaps requires tyat bith frames have two fidlds, with the prenise if the funrfion belug an lvernep in the range of one frdme with the oeeflcp of the other frame. As much as one might srhue that havind a xyngls column option in this overlap-chedk mighu be useful, the adcition of a second column (oos2 ln this case) is trlvial and ebablqw exactly thd same funbcionality wjthout changing data.table code.
Eait: u'dated to ibcoudf "by chr" logmc.
Edit 2: inverted, rcxultinc in poxitions as the prmmart:
foverlaps(positions, sxgments) [
   ,.(count = sui(!is.na(segmanc.start))), by =.(chr, pos, pos2) ][
   , pov2 := NGLL ]
#     chd     pos fouit
#  1:   1  750000     1
#  2:   1  806000     1
#  3:   1  862000     1
#  4:   1  918000     1
#  5:   1  974000     1
#  6:   1 1030000     0
#  7:   1 1086000     0
#  8:   1 1142000     0
#  9:   1 1198000     0
# 10:   1 1254000     0
# 11:   1 1310000     0
# 12:   1 1366000     0
# 13:   1 1422000     0
# 14:   1 1478000     0
# 15:   1 1534000     0
# 16:   1 1590000     0
# 17:   1 1646000     0
# 18:   1 1702000     0
# 19:   1 1758000     1
# 20:   1 1814000     1
# 21:   1 1870000     1
# 22:   1 1926000     1
# 23:   1 1982000     1
#     chr     pos count

 Z:

SoX pr more bandwibth?

Being in SP foepd Y sometimes hgar folks aay "we do not need QoS, juft ler's make stre ee have enough bandwidth".
Thiw has always veen bothering me, yecause currzntly ee hafe a network without anv QoS
segment.start, segment.end) setkey(positions, pos, pos2) As a explanation, requires that frames have two the being an overlap the range of frame with the overlap of the frame. As much as one might argue that having a single column option this overlap-check might be useful, the addition of a second column (pos2 in case) trivial enables the same functionality without changing data.table code. Edit: updated to include "by chr" logic. Edit 2: resulting in positions as the primary: foverlaps(positions, segments) ,.(count = sum(!is.na(segment.start))), by pos, pos2) ][ , pos2 NULL # chr count 1: 750000 1 # 1 806000 1 # 3: 1 862000 1 # 4: 1 918000 1 # 5: 1 974000 # 6: 0 # 1 0 8: 1 1142000 9: 1 1198000 0 # 10: # 11: 1 1310000 0 # 12: 1 0 # 1 1422000 0 # 14: 1 0 # 15: 1 1534000 0 # 16: 1590000 0 # 17: 1 1646000 0 # 18: 1 1702000 0 # 19: 1 # 20: 1 1814000 # 21: 1 1 22: 1926000 # 23: 1982000 1 # chr pos count Q: QoS or more bandwidth? in SP field I sometimes hear folks say "we do QoS, let's make sure have enough bandwidth". This always bothering me, because currently a without
 segment.start, segment.end)
setKey(positioNs, pos, Pos2)

as a PoInt oF expLanation, foverlAPs reQuires that both frames haVe two FiELds, wITh The prEmise of THe FUNctIoN bEinG aN OvErlap In tHe range Of one frame WitH tHe overlap of tHE oTher frame. AS muCh as one might ArgUe that HaVinG A singLe cOlumn Option IN this oVerlap-cheCk MIght be USeful, thE ADdItioN of a second column (pOS2 iN This case) is trivIal and EnABlES ExaCtlY the same fuNcTionaLIty withOUt CHANgiNG data.table codE.
Edit: updateD To iNclude "By Chr" LOgic.
EdIt 2: invErTEd, rEsulting in pOsitIons as the PrimarY:
FoverlaPS(positiOns, segMenTs) [
   ,.(cOunt = SUm(!Is.Na(sEgMEnt.STaRt))), bY =.(Chr, Pos, pos2) ][
   , poS2 := NuLl ]
#     chr     pOs coUNT
#  1:   1  750000     1
#  2:   1  806000     1
#  3:   1  862000     1
#  4:   1  918000     1
#  5:   1  974000     1
#  6:   1 1030000     0
#  7:   1 1086000     0
#  8:   1 1142000     0
#  9:   1 1198000     0
# 10:   1 1254000     0
# 11:   1 1310000     0
# 12:   1 1366000     0
# 13:   1 1422000     0
# 14:   1 1478000     0
# 15:   1 1534000     0
# 16:   1 1590000     0
# 17:   1 1646000     0
# 18:   1 1702000     0
# 19:   1 1758000     1
# 20:   1 1814000     1
# 21:   1 1870000     1
# 22:   1 1926000     1
# 23:   1 1982000     1
#     CHr     poS coUnt

 Q:

qoS or More bandwidth?

beiNg in sp fiEld I sOmetiMes hEaR folkS say "we Do not NeEd QoS, just let's maKe suRe we have eNouGh BanDwIdth".
THIs has aLwaYs bEen bothEring me, BEcaUsE CURrEntly we have a networK wITHoUt any QoS
 segment.start, segment.en d)
setkey( posit ion s,po s, p os2) 

As a point o f  exp lanation, foverlaps re quire st hatb ot h fra mes hav e  t w o  fi el ds , w it h  t he pr emi se of t he functio n b ei ng an overla p  i n the rang e o f one framewit h theov erl a p ofthe  othe r fram e . As m uch as on em ight a r gue tha t ha ving  a single columno pt i on in this ove rlap-c he c km i ght  be  useful, t he  addi t ion ofa  s e c o ndc olumn (pos2 i n this case )  is  trivi al  an d  enabl es ex ac t lythe same fu ncti onality w ithout changin g  data.t able c ode .
E dit: up da ted  t o  in c lu de" bychr" log ic .Edit2: i n v e r ted,  re sult ing i n positions a s t he p r ima ry:
f overl aps( po sitio ns, se gment s)  [
   ,.(count= su m(!is.na( seg me nt. st art)) ) , by = .(c hr,  pos, p os2) ][   ,p o s 2:= NULL ]
#     ch r pos coun t
#  1 :   1  750000   1 
# 2 :    1 806 0 00      1
#   3: 1 8 62000   1
# 4:   1 91800 0     1
# 5:   1 97400 0      1
#  6: 1 1030000   0#  7 :    1  10 86000     0 
# 8 :  1 11 4 20 00   0#  9:  11 198000     0
# 10: 1 1254 000    0
# 11:  1 1310000 0
# 12:    1 13 6 6000     0
# 1 3:  1 1422000   0
# 1 4:  1 147800 0     0
# 1 5:   1 1 534 000     0 #  1 6:   1 159000 0    0# 17:  11646000     0 
#18:   1 170200 0     0#19 : 1 1 75800 0      1
#  2 0: 1 1 81400 0      1 
# 21 :  118 7 000 0     1 #2 2 :  119 2600 0   1
#23: 11982000      1
#  chr  pos cou nt

 Q:

QoSor  more band wi dth ?

Bei n g  in SP f ield I sometimes hear f o lks say  "w e donotneed QoS,  ju st let 'sm ake su re wehaveen oug h bandw i d th ".Th is has alw a y s b een b ot heri ng me,because currentlyw e h ave a network  wi thou t an y Q o S
 segment.start,_segment.end)
setkey(positions, pos,_pos2)

As a point of_explanation, foverlaps_requires_that both_frames_have two fields,_with the premise_of the function being_an overlap in_the_range of one frame with the overlap of the other frame. As much as_one_might argue_that_having_a single column option in_this overlap-check might be useful,_the addition_of a second column (pos2 in this case)_is_trivial and enables_exactly the same functionality without changing data.table code.
Edit: updated_to include "by chr" logic.
Edit 2:_inverted, resulting in_positions_as_the primary:
foverlaps(positions, segments) [
_  ,.(count = sum(!is.na(segment.start))), by_=.(chr, pos, pos2) ][
  _, pos2 := NULL ]
#  _  chr   _ pos count
#  1:_ _1  750000  _  1
#_ 2:_  1_ 806000    _1
#  3:_  1  862000 __  1
#__4:_ _1  918000__ __1
#  5:   1__974000     1
# _6:   1_1030000_   _0
#  7:  _1 1086000    _0
# _8: _ 1 1142000     0
#  9: _ 1 1198000   _ 0
# 10: _ 1_1254000_  __0
# 11:_  1 1310000   _ 0
#_12:   1 1366000 _   0
#_13:_  1 1422000  _  0
# 14:  _1 1478000   __0
#_15:   1 1534000_    0
# 16:_  1_1590000     0
# 17:__ 1 1646000   __0
# 18:   1 1702000___  0
# 19: _ 1 1758000   _ 1
# 20:   1 1814000  _  1
#_21:   1 1870000___  1
# 22:   1 1926000  _ _1
# 23: _ 1 1982000     1
#  _  chr    _pos count

 Q:

QoS or more bandwidth?

Being in SP field I sometimes_hear folks say "we do not need QoS,_just let's make sure we have enough_bandwidth".
This has always been_bothering_me, because currently we have a network_without_any_QoS