-1

I have a large csv file with more than 1M rows and it looks like the following

zip,name,age,...
50010,betty,34
50010,roger,28
50011,tom,24,1.73
50011,petet,30,1,81
50014,curie,43,1.63,40000
50014,chris,34,1.72,50000

I want to read this file into separated lists or data frames so that each data frame contains rows with same zip code (first column). In the previous example, there will be three data frames with different number of columns. How could I accomplish this?

user2100721
  • 3,557
  • 2
  • 20
  • 29
Ruolin Liu
  • 151
  • 2
  • 5
  • 3
    Possible duplicate of [Split a large dataframe into a list of data frames based on common value in column](http://stackoverflow.com/questions/18527051/split-a-large-dataframe-into-a-list-of-data-frames-based-on-common-value-in-colu) Or [Split data.frame based on levels of a factor into new data.frames](http://stackoverflow.com/questions/9713294/split-data-frame-based-on-levels-of-a-factor-into-new-data-frames) Or [Split/subset a data frame by factors in one column](http://stackoverflow.com/questions/19327020/split-subset-a-data-frame-by-factors-in-one-column) – Ronak Shah Jan 19 '17 at 08:00
  • 1
    Or [split data frame into two by column value](http://stackoverflow.com/questions/26287706/split-data-frame-into-two-by-column-value) – Ronak Shah Jan 19 '17 at 08:04

1 Answers1

0

We can use split after reading the dataset

lst <- split(df1, df1$zip)
akrun
  • 874,273
  • 37
  • 540
  • 662