You can do something like this
library(tidyverse)
library(stargazer)
iris %>%
group_nest(Species) %>%
mutate(model = map(data, ~ lm(Sepal.Length ~ Sepal.Width, data = .x))) %>%
walk2(.x = .$model,
.y = .$Species,
.f = ~stargazer(.x, title = "Regression Results",
type = "html",
out = paste(.y, ".html")))