
iris %&gt;%
  split(.$Species) %&gt;%
  map(select, -Species) %&gt;%
  iwalk(~ write_tsv(.x, paste0(.y, &quot;.tsv&quot;)))

# Show the files
iris_files &lt;- dir_ls(glob = &quot;*.tsv&quot;)
iris_files
#&gt; setosa.tsv     versicolor.tsv virginica.tsv

# Read the data into a single table, including the filenames
iris_files %&gt;%
  map_df(read_tsv, .id = &quot;file&quot;, col_types = cols(), n_max = 2)
#&gt; # A tibble: 6 x 5
#&gt;   file           Sepal.Length Sepal.Width Petal.Length Petal.Width
#&gt;  