R data.table与roll连接

时间:2016-08-24 11:14:20

标签: r data.table

  <div class="row">
  <div class="col-md-1"></div>
  <div class="col-md-10">
    <div class="panel mepanelo">
      <div class="row ">
        <div class="col-md-4 col-sm-6 big_list">
          <ul class="list1">
            <li><a class="btn" role="button" href="figurini.php">Figurini</a>
            </li>
            <li><a class="btn" role="button" href="mezzi.php">Mezzi Militari</a>
            </li>
            <li><a class="btn" role="button" href="accessori.php">Accessori</a>
            </li>
            <li><a class="btn" role="button" href="strumenti.php">Strumenti</a>
            </li>
            <!-- follwing elements are hidden on all devices except small (tablets) -->
            <li class="hidden-xs hidden-md hidden-lg"> 
              <a class="btn" role="button" href="busti.php">Busti</a>
            </li>
            <li class="hidden-xs hidden-md hidden-lg"> 
              <a class="btn" role="button" href="navi.php">Navi</a>
            </li>

          </ul>
        </div>
        <div class="col-md-4 col-sm-6 big_list">
          <ul class="list1  ">
            <li><a class="btn" role="button" href="fantasy.php">Fantasy</a>
            </li>
            <li><a class="btn" role="button" href="aerei.php">Aerei</a>
            </li>
            <li><a class="btn" role="button" href="ambientazioni.php">Ambientazioni</a>
            </li>
            <li><a class="btn" role="button" href="edizioni.php">Edizioni</a>
            </li>
            <!-- follwing elements are hidden on all devices except small (tablets) -->
            <li class="hidden-xs hidden-md hidden-lg"><a class="btn" role="button" href="colori.php">Colori</a>
            </li>
            <li class="hidden-xs hidden-md hidden-lg" ><a class="btn" role="button" href="occasioni.php">Occasioni</a>
            </li>

          </ul>
        </div>
        <div class="col-md-4 hidden-sm big_list"> <!-- hidden on small devices -->
          <ul class="list1">
            <li><a class="btn" role="button" href="busti.php">Busti</a>
            </li>
            <li><a class="btn" role="button" href="navi.php">Navi</a>
            </li>
            <li><a class="btn" role="button" href="colori.php">Colori</a>
            </li>
            <li><a class="btn" role="button" href="occasioni.php">Occasioni</a>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
  <div class="col-md-1"></div>
</div>

我错过了什么?为什么dd = data.table(a = c(1,1), b = c(1,2), v = c(1, NA)) dd # a b v # 1: 1 1 1 # 2: 1 2 NA setkey(dd, a,b) dd[.(1,2), roll = TRUE, rollends = c(TRUE, TRUE)] # a b v # 1: 1 2 NA 没有结转?

1 个答案:

答案 0 :(得分:2)

滚动连接不需要在此处滚动,因为您匹配确切的行(1, 2)。当实际值不匹配时进行滚动匹配,在您的情况下,它具有完全匹配。请参阅以下示例,我修改了dd,因此.(1,2)上没有匹配。

library(data.table)
dd = data.table(a = c(1,1), b = c(1,3), v = c(1, NA))
dd[.(1,2), roll = TRUE, rollends = c(TRUE, TRUE)]
#   a b v
#1: 1 2 1

请参阅?data.table // roll(强调我的):

  

idata.table且其行与匹配除最后一个x加入列以外的所有内容时,以及其在i中的值}连接列落在一个间隙中(包括在该组的x中的最后一次观察之后),然后:

     
      
  • +Inf(或TRUE)在x向前滚动盛行值。它也被称为最后一次观察(LOCF)
  •   
     

...