How to split a data frame?

后端 未结 8 2613
臣服心动
臣服心动 2020-11-22 03:08

I want to split a data frame into several smaller ones. This looks like a very trivial question, however I cannot find a solution from web search.

8条回答
  •  無奈伤痛
    2020-11-22 03:23

    If you want to split by values in one of the columns, you can use lapply. For instance, to split ChickWeight into a separate dataset for each chick:

    data(ChickWeight)
    lapply(unique(ChickWeight$Chick), function(x) ChickWeight[ChickWeight$Chick == x,])
    

提交回复
热议问题