rdplyrsplit

Split one table to multiple tables


Actually I have a big table that I want to split to multiple tables based on specific column's values. For that I use the subset function like this :

lapply(1:18, function(i) subset(table,bucket==i))

The problem is that I don't know how to assign each mini-table to its name like table_1 for i=1, table_2 for i=2 ...


Solution

  • I did this and it works :

    for (i in unique(table$bucket))
    {
      assign(  paste("table_", i, sep = ""), subset(table,bucket==i) )
    }
    

    Do you know if there is a way to avoid using the For loop?