Split dataframe into multiple output files

Using lapply over the names of spt1 will allow us to access the dataframes in spt1 and the name that we can use in paste to create our files.

lapply(names(spt1), function(x){write.table(spt1[[x]], file = paste("output", x, sep = ""))})

You could add a common extension in the paste if you want.

Leave a Comment