search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

Advanced R Tutorial – Use SDcols In data.table | ARON HACK 亞倫害的

目錄

SDcols is an useful but tricky method in data.table. The statement of it is hard to remember, so I wrote down some examples, copying and pasting when I need them.

Use lapply with .SDcols

cols % 
  .[,  c(cols):= lapply(.SD, function(x) ifelse(is.na(x), 0, x))
    , .SDcols = cols]

Aggregate with .SDcols

cols_by %
  .[, lapply(.SD, sum), by = item_no_col, .SDcols = cols_sum]

Recommended Posts

Learn Python And R In DataCamp. Start Your Data Science Career.

Content Protection by DMCA.com


熱門推薦

本文由 aronhackcom 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦