title: How to transform this data, map() to tune()
body: <p>An iterative process is used to compare machine learning models.</p>
  <p>I was able to find the k-neighbor method in parsnip, but can I modify it to
  k-means to create something similar to the above code?<br />
  Do you have any information that might be useful?</p>
  <p>To make the code easier to understand, I want to tune the K using tune().</p>
  <pre><code>poi &lt;- tibble(
    cluster = factor(1:3),num_points = c(100, 150, 50),
    x1 = c(5, 0, -3),x2 = c(-1, 1, -2))%&gt;%
    mutate(
      x1 = map2(num_points, x1, rnorm),
      x2 = map2(num_points, x2, rnorm)) %&gt;% 
    unnest(cols = c(x1, x2)) %&gt;%
    select(-cluster,-num_points)
  
  res &lt;- 
    tibble(k = 1:9) %&gt;%
    mutate(
      kclust = map(k, ~kmeans(poi, .x)),
      augmented = map(kclust, augment, poi)
    )
  </code></pre>