You just have to make sure the names are sorted, see the example:
XMRTest2 <- data.frame(stringsAsFactors=FALSE,
TeamName = c("Team6", "Team6", "Team6", "Team3", "Team3", "Team3",
"Team3", "Team3", "Team3", "Team3", "Team3", "Team3",
"Team3", "Team3", "Team3", "Team6", "Team6", "Team6", "Team3",
"Team3", "Team3", "Team3", "Team3", "Team3", "Team3", "Team3",
"Team3", "Team3", "Team3", "Team3"),
FMonthYear = c("FY2018 M11", "FY2018 M10", "FY2018 M12", "FY2018 M01",
"FY2018 M05", "FY2018 M09", "FY2018 M11", "FY2018 M10",
"FY2018 M04", "FY2018 M03", "FY2018 M12", "FY2018 M02",
"FY2018 M08", "FY2018 M07", "FY2018 M06", "FY2018 M11", "FY2018 M10",
"FY2018 M12", "FY2018 M01", "FY2018 M05", "FY2018 M09",
"FY2018 M11", "FY2018 M10", "FY2018 M04", "FY2018 M03", "FY2018 M12",
"FY2018 M02", "FY2018 M08", "FY2018 M07", "FY2018 M06"),
TeamMetric = c("Team6-Metric3", "Team6-Metric3", "Team6-Metric3",
"Team3-Metric3", "Team3-Metric3", "Team3-Metric3",
"Team3-Metric3", "Team3-Metric3", "Team3-Metric3", "Team3-Metric3",
"Team3-Metric3", "Team3-Metric3", "Team3-Metric3", "Team3-Metric3",
"Team3-Metric3", "Team6-Metric6", "Team6-Metric6",
"Team6-Metric6", "Team3-Metric6", "Team3-Metric6", "Team3-Metric6",
"Team3-Metric6", "Team3-Metric6", "Team3-Metric6", "Team3-Metric6",
"Team3-Metric6", "Team3-Metric6", "Team3-Metric6",
"Team3-Metric6", "Team3-Metric6"),
MetricName = c("Metric3", "Metric3", "Metric3", "Metric3", "Metric3",
"Metric3", "Metric3", "Metric3", "Metric3", "Metric3",
"Metric3", "Metric3", "Metric3", "Metric3", "Metric3", "Metric6",
"Metric6", "Metric6", "Metric6", "Metric6", "Metric6", "Metric6",
"Metric6", "Metric6", "Metric6", "Metric6", "Metric6",
"Metric6", "Metric6", "Metric6"),
Value = c(355, 3, 1286, 209, 149, 112, 138, 147, 181, 179, 35, 196,
160, 90, 68, 25.35714286, 1, 48.11111111, 1.445783133,
1.330882353, 1.265306122, 1.394495413, 1.302325581, 1.623188406,
1.386666667, 1.166666667, 1.496402878, 1.384057971, 1.432098765,
1.594594595)
)
library(xmrr)
library(tidyverse)
Output <- XMRTest2 %>%
group_nest(TeamMetric) %>%
arrange(TeamMetric) %>%
pull(data) %>%
setNames(nm = sort(unique(XMRTest2$TeamMetric))) %>%
map_dfr(~xmr(., measure = "Value"), .id = "TeamMetric")
Output
#> # A tibble: 30 x 11
#> TeamMetric TeamName FMonthYear MetricName Value Order `Central Line`
#> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 Team3-Met… Team3 FY2018 M01 Metric3 209 1 151
#> 2 Team3-Met… Team3 FY2018 M05 Metric3 149 2 151
#> 3 Team3-Met… Team3 FY2018 M09 Metric3 112 3 151
#> 4 Team3-Met… Team3 FY2018 M11 Metric3 138 4 151
#> 5 Team3-Met… Team3 FY2018 M10 Metric3 147 5 151
#> 6 Team3-Met… Team3 FY2018 M04 Metric3 181 6 151
#> 7 Team3-Met… Team3 FY2018 M03 Metric3 179 7 151
#> 8 Team3-Met… Team3 FY2018 M12 Metric3 35 8 151
#> 9 Team3-Met… Team3 FY2018 M02 Metric3 196 9 151
#> 10 Team3-Met… Team3 FY2018 M08 Metric3 160 10 151
#> # … with 20 more rows, and 4 more variables: `Moving Range` <dbl>,
#> # `Average Moving Range` <dbl>, `Lower Natural Process Limit` <dbl>,
#> # `Upper Natural Process Limit` <dbl>
Created on 2019-09-10 by the reprex package (v0.3.0)