Applying a function to each row of a data.table

前端 未结 7 1293
日久生厌
日久生厌 2020-12-03 10:46

I looking for a way to efficiently apply a function to each row of data.table. Let\'s consider the following data table:

library(data.table)
library(stringr)         


        
7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 11:19

    x[, .(a,strsplit(b,' ')), by=1:nrow(x)]
    

    by=nrow(x) is a simple way to force 1 row per by-group

提交回复
热议问题