R packages: dplyr拾遺

來源:互聯網
上載者:User

dplyr是HW的資料處理的利器

dplyr的介紹dplyr

備忘: distinct去重

distinct(select(flights, tailnum))#> Source: local data frame [4,044 x 1]#> #>    tailnum#>      (chr)#> 1   N14228#> 2   N24211#> 3   N619AA#> 4   N804JB#> ..     ...
sample_n; sample_frac抽樣
sample_n(flights, 10)#> Source: local data frame [10 x 16]#> #>     year month   day dep_time dep_delay arr_time arr_delay carrier tailnum#>    (int) (int) (int)    (int)     (dbl)    (int)     (dbl)   (chr)   (chr)#> 1   2013     6    12     1428        -7     1733       -17      DL  N370NW#> 2   2013     3    23      600        -7      955        23      UA  N510UA#> 3   2013     3    29     1814        14     1920         3      B6  N238JB#> 4   2013     2    25     1957       -10     2156       -10      EV  N19966#> ..   ...   ...   ...      ...       ...      ...       ...     ...     ...#> Variables not shown: flight (int), origin (chr), dest (chr), air_time#>   (dbl), distance (dbl), hour (dbl), minute (dbl)sample_frac(flights, 0.01)#> Source: local data frame [3,368 x 16]#> #>     year month   day dep_time dep_delay arr_time arr_delay carrier tailnum#>    (int) (int) (int)    (int)     (dbl)    (int)     (dbl)   (chr)   (chr)#> 1   2013     5     7     1156        -4     1321       -17      UA  N432UA#> 2   2013     4    18     1543        -5     1755       -25      DL  N369NB#> 3   2013     3    26     1408        -7     1623        -8      DL  N344NB#> 4   2013     1    24     2001        66     2211        71      MQ  N526MQ#> ..   ...   ...   ...      ...       ...      ...       ...     ...     ...#> Variables not shown: flight (int), origin (chr), dest (chr), air_time#>   (dbl), distance (dbl), hour (dbl), minute (dbl)
top_n

排名前n的 lag

實現diff類的功能 tally

summarise(n())

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.